Skip to content

Commit f2348a5

Browse files
committed
Upgrade PyLint to 3.3
1 parent be5ecfb commit f2348a5

10 files changed

Lines changed: 98 additions & 201 deletions

File tree

.pylint.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ disable=
2525
too-many-nested-blocks,
2626
protected-access,
2727
unspecified-encoding,
28+
deprecated-class,
2829
# Disabling these helps to write more expressive tests:
2930
expression-not-assigned,
3031
blacklisted-name,
@@ -37,6 +38,7 @@ disable=
3738
cyclic-import,
3839
comparison-with-callable,
3940
unsupported-binary-operation,
41+
invalid-field-call,
4042

4143
init-import=yes
4244

datafiles/converters/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ def map_type(cls, *, name: str = "", item_cls: Optional[type] = None):
7878
except AttributeError as e: # Python 3.9 behavior
7979
assert "__args__" in str(e), f"Unhandled error: {e}"
8080
raise TypeError("Type is required with 'List' annotation") from None
81-
else:
82-
converter = List.of_type(converter)
81+
converter = List.of_type(converter)
8382

8483
elif cls.__origin__ == set:
8584
try:
@@ -90,8 +89,7 @@ def map_type(cls, *, name: str = "", item_cls: Optional[type] = None):
9089
except AttributeError as e: # Python 3.9 behavior
9190
assert "__args__" in str(e), f"Unhandled error: {e}"
9291
raise TypeError("Type is required with 'Set' annotation") from None
93-
else:
94-
converter = Set.of_type(converter)
92+
converter = Set.of_type(converter)
9593

9694
elif isclass(cls.__origin__) and issubclass(cls.__origin__, Mapping):
9795
if item_cls:

datafiles/converters/builtins.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ def to_preserialization_data(cls, python_value, *, default_to_skip=None):
4545
data = cls.TYPE(float(python_value))
4646
except ValueError:
4747
raise exc from None
48-
else:
49-
log.warn(f"Precision lost in conversion to int: {python_value}")
50-
return data
48+
log.warn(f"Precision lost in conversion to int: {python_value}")
49+
return data
5150

5251

5352
class String(Converter, str):

datafiles/converters/containers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ def of_mappings(cls, dataclass, converters: Dict[str, type]):
178178
@classmethod
179179
def to_python_value(cls, deserialized_data, *, target_object=None):
180180
if dataclasses.is_dataclass(deserialized_data):
181+
assert not isinstance(
182+
deserialized_data, type
183+
), "Expected dataclass instance, not class"
181184
data = dataclasses.asdict(deserialized_data)
182185
elif isinstance(deserialized_data, dict):
183186
data = deserialized_data.copy()

datafiles/hooks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def apply(instance, mapper):
4848
setattr(cls, method_name, modified_method)
4949

5050
if is_dataclass(instance):
51-
for attr_name in instance.datafile.attrs:
51+
for attr_name in instance.datafile.attrs: # type: ignore
5252
attr = getattr(instance, attr_name)
5353
if isinstance(attr, list):
5454
attr = types.List(attr)
@@ -64,7 +64,7 @@ def apply(instance, mapper):
6464
elif isinstance(instance, list):
6565
for item in instance:
6666
if is_dataclass(item):
67-
item.datafile = create_mapper(item, root=mapper)
67+
item.datafile = create_mapper(item, root=mapper) # type: ignore
6868
apply(item, mapper)
6969

7070
elif isinstance(instance, dict):

datafiles/mapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __init__(
3535
self._instance = instance
3636
self._frozen = (
3737
dataclasses.is_dataclass(self._instance)
38-
and self._instance.__dataclass_params__.frozen
38+
and self._instance.__dataclass_params__.frozen # type: ignore[union-attr]
3939
)
4040
self.attrs = attrs
4141
self._pattern = pattern

datafiles/model.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,22 @@ def create_model(
6868
if not hasattr(cls, "Meta") and infer is not None:
6969
meta.datafile_infer = infer
7070

71-
cls.Meta = meta
71+
cls.Meta = meta # type: ignore
7272

7373
# Patch manager
7474

75-
cls.objects = Manager(cls)
75+
cls.objects = Manager(cls) # type: ignore
7676

7777
# Patch __init__
7878

79-
init = cls.__init__
79+
init = cls.__init__ # type: ignore
8080

8181
def modified_init(self, *args, **kwargs):
8282
with hooks.disabled():
8383
init(self, *args, **kwargs)
8484
Model.__post_init__(self)
8585

86-
cls.__init__ = modified_init
87-
cls.__init__.__doc__ = init.__doc__
86+
cls.__init__ = modified_init # type: ignore
87+
cls.__init__.__doc__ = init.__doc__ # type: ignore
8888

8989
return cls

datafiles/plugins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# pylint: disable=no-name-in-module,unused-argument
1+
# pylint: disable=no-name-in-module,unused-argument,no-value-for-parameter
22

33
from typing import Callable, Optional
44

poetry.lock

Lines changed: 78 additions & 183 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ black = "^24.3"
6464
isort = "^5.10"
6565

6666
# Linters
67-
mypy = "^1.3"
68-
pylint = "~2.15"
67+
mypy = "^1.18.1"
68+
pylint = "~3.3.8"
6969
pydocstyle = "*"
7070

7171
# Testing

0 commit comments

Comments
 (0)