Skip to content

Commit f32e473

Browse files
committed
test: 🚨 Fix complaints from various linters
1 parent 32a47e9 commit f32e473

File tree

6 files changed

+19
-21
lines changed

6 files changed

+19
-21
lines changed

diffsync/__init__.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,29 @@
1818
import sys
1919
from inspect import isclass
2020
from typing import (
21+
Any,
2122
Callable,
2223
ClassVar,
2324
Dict,
2425
List,
2526
Optional,
27+
Set,
2628
Tuple,
2729
Type,
2830
Union,
29-
Any,
30-
Set,
3131
)
32-
from typing_extensions import deprecated
3332

34-
from pydantic import ConfigDict, BaseModel, PrivateAttr
3533
import structlog # type: ignore
34+
from pydantic import BaseModel, ConfigDict, PrivateAttr
35+
from typing_extensions import deprecated
3636

3737
from diffsync.diff import Diff
38-
from diffsync.enum import DiffSyncModelFlags, DiffSyncFlags, DiffSyncStatus
38+
from diffsync.enum import DiffSyncFlags, DiffSyncModelFlags, DiffSyncStatus
3939
from diffsync.exceptions import (
4040
DiffClassMismatch,
4141
ObjectAlreadyExists,
42-
ObjectStoreWrongType,
4342
ObjectNotFound,
43+
ObjectStoreWrongType,
4444
)
4545
from diffsync.helpers import DiffSyncDiffer, DiffSyncSyncer
4646
from diffsync.store import BaseStore
@@ -134,16 +134,16 @@ def __pydantic_init_subclass__(cls, **kwargs: Any) -> None:
134134
"""
135135
# Make sure that any field referenced by name actually exists on the model
136136
for attr in cls._identifiers:
137-
if attr not in cls.model_fields and not hasattr(cls, attr):
137+
if attr not in cls.model_fields and not hasattr(cls, attr): # pylint: disable=unsupported-membership-test
138138
raise AttributeError(f"_identifiers {cls._identifiers} references missing or un-annotated attr {attr}")
139139
for attr in cls._shortname:
140-
if attr not in cls.model_fields:
140+
if attr not in cls.model_fields: # pylint: disable=unsupported-membership-test
141141
raise AttributeError(f"_shortname {cls._shortname} references missing or un-annotated attr {attr}")
142142
for attr in cls._attributes:
143-
if attr not in cls.model_fields:
143+
if attr not in cls.model_fields: # pylint: disable=unsupported-membership-test
144144
raise AttributeError(f"_attributes {cls._attributes} references missing or un-annotated attr {attr}")
145145
for attr in cls._children.values():
146-
if attr not in cls.model_fields:
146+
if attr not in cls.model_fields: # pylint: disable=unsupported-membership-test
147147
raise AttributeError(f"_children {cls._children} references missing or un-annotated attr {attr}")
148148

149149
# Any given field can only be in one of (_identifiers, _attributes, _children)

diffsync/diff.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
"""
1717

1818
from functools import total_ordering
19-
from typing import Any, Iterator, Optional, Type, List, Dict, Iterable
19+
from typing import Any, Dict, Iterable, Iterator, List, Optional, Type
2020

21-
from .exceptions import ObjectAlreadyExists
22-
from .utils import intersection, OrderedDefaultDict
2321
from .enum import DiffSyncActions
22+
from .exceptions import ObjectAlreadyExists
23+
from .utils import OrderedDefaultDict, intersection
2424

2525
# This workaround is used because we are defining a method called `str` in our class definition, which therefore renders
2626
# the builtin `str` type unusable.
@@ -105,7 +105,7 @@ def order_children_default(cls, children: Dict[StrType, "DiffElement"]) -> Itera
105105
106106
Since children is already an OrderedDefaultDict, this method is not doing anything special.
107107
"""
108-
for child in children.values():
108+
for child in children.values(): # pylint: disable=use-yield-from
109109
yield child
110110

111111
def summary(self) -> Dict[StrType, int]:

diffsync/store/redis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
class RedisStore(BaseStore):
2525
"""RedisStore class."""
2626

27-
def __init__(
27+
def __init__( # pylint: disable=too-many-arguments
2828
self,
2929
*args: Any,
3030
store_id: Optional[str] = None,

examples/02-callback-function/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
See the License for the specific language governing permissions and
1616
limitations under the License.
1717
"""
18+
1819
import random
1920

2021
from diffsync import Adapter, DiffSyncModel
@@ -40,7 +41,7 @@ class Adapter1(Adapter):
4041
def load(self, count): # pylint: disable=arguments-differ
4142
"""Construct Numbers from 1 to count."""
4243
for i in range(count):
43-
self.add(Number(number=(i + 1)))
44+
self.add(Number(number=i + 1))
4445

4546

4647
class Adapter2(Adapter):

examples/03-remote-system/nautobot_models.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
"""Extension of the Base model for the Nautobot DiffSync Adapter to manage the CRUD operations."""
22

33
import pynautobot # pylint: disable=import-error
4-
5-
from models import Region, Country # pylint: disable=no-name-in-module
4+
from models import Country, Region # pylint: disable=no-name-in-module
65

76
from diffsync import Adapter
87

9-
108
# pylint: disable=no-member,too-few-public-methods
119

1210

@@ -51,7 +49,7 @@ def create(cls, adapter: Adapter, ids: dict, attrs: dict):
5149
country = adapter.nautobot.dcim.regions.create(
5250
slug=ids.get("slug"),
5351
name=attrs.get("name"),
54-
custom_fields=dict(population=attrs.get("population")),
52+
custom_fields={"population": attrs.get("population")},
5553
parent=region.remote_id,
5654
)
5755
print(f"Created country : {ids} | {attrs} | {country.id}")

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ no-docstring-rgx="^(_|test_)"
8484
# Pylint and Black disagree about how to format multi-line arrays; Black wins.
8585
disable = """,
8686
line-too-long,
87-
bad-continuation,
8887
"""
8988

9089
[tool.pylint.miscellaneous]

0 commit comments

Comments
 (0)