Skip to content

Commit 3386091

Browse files
author
César Román
authored
refactor: add call to super in base classes (#111)
update sourcery configuration file add strictness to mypy check <https://eugeneyan.com/writing/uncommon-python/>
1 parent 72c1730 commit 3386091

File tree

6 files changed

+40
-24
lines changed

6 files changed

+40
-24
lines changed

Diff for: .sourcery.yaml

+26-16
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,37 @@
1-
ignore: []
1+
version: '1'
22

3-
refactor:
4-
include: []
5-
skip:
6-
- dict-assign-update-to-union
7-
- lift-return-into-if
8-
- use-fstring-for-formatting
3+
ignore:
4+
- .git
5+
- .env
6+
- .tox
7+
- .venv
8+
- env
9+
- venv
10+
11+
rule_settings:
12+
enable:
13+
- default
14+
disable:
15+
- dict-assign-update-to-union
16+
- lift-return-into-if
17+
- use-fstring-for-formatting
918
rule_types:
10-
- refactoring
11-
- suggestion
12-
- comment
19+
- refactoring
20+
- suggestion
21+
- comment
1322
python_version: '3.10'
1423

1524
metrics:
1625
quality_threshold: 25.0
1726

18-
clone_detection:
19-
min_lines: 3
20-
min_duplicates: 2
21-
identical_clones_only: false
22-
2327
github:
2428
labels: []
25-
ignore_labels: [sourcery-ignore]
29+
ignore_labels:
30+
- sourcery-ignore
2631
request_review: author
2732
sourcery_branch: sourcery/{base_branch}
33+
34+
clone_detection:
35+
min_lines: 3
36+
min_duplicates: 2
37+
identical_clones_only: false

Diff for: src/incendium/dataset.py

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def __init__(self, root="root", indent="\t"):
2626
root: The value of the XML root element.
2727
indent: Character(s) used for indentation.
2828
"""
29+
super(_NanoXML, self).__init__()
2930
self.root = root
3031
self.indent = indent
3132
self._new_line = "\n"

Diff for: src/incendium/db.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def __init__(self, database, retries=3):
4545
retries: The number of additional times to retry
4646
enabling the connection. Optional.
4747
"""
48+
super(DisposableConnection, self).__init__()
4849
self.database = database
4950
self.retries = retries
5051

@@ -111,11 +112,12 @@ def __init__(
111112
type_code: Type code constant.
112113
value: Value of type type_code.
113114
"""
115+
super(Param, self).__init__()
114116
self._name_or_index = name_or_index
115117
self._type_code = type_code
116118
self._value = value
117119

118-
def __repr__(self):
120+
def __repr__(self): # type: ignore[no-untyped-def]
119121
"""Compute the "official" string representation."""
120122
return "{}(name_or_index={!r}, type_code={}, value={})".format(
121123
self.__class__.__name__,
@@ -124,7 +126,7 @@ def __repr__(self):
124126
self.value,
125127
)
126128

127-
def __str__(self):
129+
def __str__(self): # type: ignore[no-untyped-def]
128130
"""Compute the "informal" string representation."""
129131
return "{!r}, {}, {}".format(self.name_or_index, self.type_code, self.value)
130132

Diff for: src/incendium/exceptions.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ def __init__(
3232
inner_exception: The inner Exception. Optional.
3333
cause: The cause of the Exception. Optional.
3434
"""
35+
super(ApplicationError, self).__init__()
3536
self.message = message
3637
self.inner_exception = inner_exception
3738
self.cause = cause
38-
super(ApplicationError, self).__init__(message)
3939

40-
def __repr__(self):
40+
def __repr__(self): # type: ignore[no-untyped-def]
4141
"""Compute the "official" string representation."""
4242
return "{}(message={!r}, inner_exception={!r}, cause={!r})".format(
4343
self.__class__.__name__,
@@ -46,7 +46,7 @@ def __repr__(self):
4646
self.cause,
4747
)
4848

49-
def __str__(self):
49+
def __str__(self): # type: ignore[no-untyped-def]
5050
"""Compute the "informal" string representation."""
5151
return "{!r}, {!r}, {!r}".format(self.message, self.inner_exception, self.cause)
5252

@@ -63,13 +63,13 @@ def __init__(self, message):
6363
Args:
6464
message: The error message.
6565
"""
66+
super(TagError, self).__init__()
6667
self.message = message
67-
super(TagError, self).__init__(message)
6868

69-
def __repr__(self):
69+
def __repr__(self): # type: ignore[no-untyped-def]
7070
"""Compute the "official" string representation."""
7171
return "{}(message={!r})".format(self.__class__.__name__, self.message)
7272

73-
def __str__(self):
73+
def __str__(self): # type: ignore[no-untyped-def]
7474
"""Compute the "informal" string representation."""
7575
return repr(self.message)

Diff for: src/incendium/user.py

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def __init__(self, user):
3939
Args:
4040
user: Ignition's user object.
4141
"""
42+
super(IncendiumUser, self).__init__()
4243
self._contact_info = user.getContactInfo()
4344
self._email = None
4445
self._first_name = user.get(user.FirstName)

Diff for: tox.ini

+2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ profile = black
4040
py_version = 27
4141

4242
[mypy]
43+
enable_error_code = ignore-without-code
4344
mypy_path = src
4445
python_version = 2.7
46+
strict = true
4547
warn_return_any = true
4648

4749
[pydocstyle]

0 commit comments

Comments
 (0)