Skip to content

Commit 45df339

Browse files
authored
Remove upper Limit on Packaging (#289)
* build: ⬆️ Remove upper lmit on packaging * style: 🚨 Formatting for black * style: 🚨 Address linter complaints * refactor: 🚨 Change to nosec * test: 🚨 Fix complaints from various linters * ci: 👷 Update CI to use poetry setup v6 and specify ver 1.8.5 * build: ⬆️ Make Python 3.9 minimum for project as 3.8 is EOL. * ci: 👷 Update CI to remove py 3.8 and set Poetry to 1.8.5 * test: 🚨 Address linter complaints * build: 🏗️ Update PYTHON_VER to 3.9.2 in Dockerfile and compose * test: 🚨 Address pylint complaint
1 parent b0a624e commit 45df339

31 files changed

+1064
-1035
lines changed

.github/workflows/ci.yml

+27-11
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ jobs:
2929
- name: "Check out repository code"
3030
uses: "actions/checkout@v2"
3131
- name: "Setup environment"
32-
uses: "networktocode/gh-action-setup-poetry-environment@v5"
32+
uses: "networktocode/gh-action-setup-poetry-environment@v6"
33+
with:
34+
poetry-version: "1.8.5"
3335
- name: "Linting: black"
3436
run: "poetry run invoke black"
3537
bandit:
@@ -40,7 +42,9 @@ jobs:
4042
- name: "Check out repository code"
4143
uses: "actions/checkout@v2"
4244
- name: "Setup environment"
43-
uses: "networktocode/gh-action-setup-poetry-environment@v5"
45+
uses: "networktocode/gh-action-setup-poetry-environment@v6"
46+
with:
47+
poetry-version: "1.8.5"
4448
- name: "Linting: bandit"
4549
run: "poetry run invoke bandit"
4650
needs:
@@ -53,7 +57,9 @@ jobs:
5357
- name: "Check out repository code"
5458
uses: "actions/checkout@v2"
5559
- name: "Setup environment"
56-
uses: "networktocode/gh-action-setup-poetry-environment@v5"
60+
uses: "networktocode/gh-action-setup-poetry-environment@v6"
61+
with:
62+
poetry-version: "1.8.5"
5763
- name: "Linting: pydocstyle"
5864
run: "poetry run invoke pydocstyle"
5965
needs:
@@ -66,7 +72,9 @@ jobs:
6672
- name: "Check out repository code"
6773
uses: "actions/checkout@v2"
6874
- name: "Setup environment"
69-
uses: "networktocode/gh-action-setup-poetry-environment@v5"
75+
uses: "networktocode/gh-action-setup-poetry-environment@v6"
76+
with:
77+
poetry-version: "1.8.5"
7078
- name: "Linting: flake8"
7179
run: "poetry run invoke flake8"
7280
needs:
@@ -79,7 +87,9 @@ jobs:
7987
- name: "Check out repository code"
8088
uses: "actions/checkout@v2"
8189
- name: "Setup environment"
82-
uses: "networktocode/gh-action-setup-poetry-environment@v5"
90+
uses: "networktocode/gh-action-setup-poetry-environment@v6"
91+
with:
92+
poetry-version: "1.8.5"
8393
- name: "Linting: mypy"
8494
run: "poetry run invoke mypy"
8595
needs:
@@ -92,7 +102,9 @@ jobs:
92102
- name: "Check out repository code"
93103
uses: "actions/checkout@v2"
94104
- name: "Setup environment"
95-
uses: "networktocode/gh-action-setup-poetry-environment@v5"
105+
uses: "networktocode/gh-action-setup-poetry-environment@v6"
106+
with:
107+
poetry-version: "1.8.5"
96108
- name: "Linting: yamllint"
97109
run: "poetry run invoke yamllint"
98110
needs:
@@ -103,7 +115,9 @@ jobs:
103115
- name: "Check out repository code"
104116
uses: "actions/checkout@v2"
105117
- name: "Setup environment"
106-
uses: "networktocode/gh-action-setup-poetry-environment@v5"
118+
uses: "networktocode/gh-action-setup-poetry-environment@v6"
119+
with:
120+
poetry-version: "1.8.5"
107121
- name: "Build Container"
108122
run: "poetry run invoke build"
109123
needs:
@@ -118,7 +132,9 @@ jobs:
118132
- name: "Check out repository code"
119133
uses: "actions/checkout@v2"
120134
- name: "Setup environment"
121-
uses: "networktocode/gh-action-setup-poetry-environment@v5"
135+
uses: "networktocode/gh-action-setup-poetry-environment@v6"
136+
with:
137+
poetry-version: "1.8.5"
122138
- name: "Build Container"
123139
run: "poetry run invoke build"
124140
- name: "Linting: Pylint"
@@ -129,8 +145,8 @@ jobs:
129145
strategy:
130146
fail-fast: true
131147
matrix:
132-
python-version: ["3.8", "3.9", "3.10", "3.11"]
133-
poetry-version: ["1.5.1"]
148+
python-version: ["3.9", "3.10", "3.11"]
149+
poetry-version: ["1.8.5"]
134150
runs-on: "ubuntu-24.04"
135151
env:
136152
PYTHON_VER: "${{ matrix.python-version }}"
@@ -140,7 +156,7 @@ jobs:
140156
- name: "Setup environment"
141157
uses: "networktocode/gh-action-setup-poetry-environment@3ea5d3ecf382cdcb0c74d4c0ff0629d95fce63c7"
142158
env:
143-
POETRY_VERSION: 1.5.1
159+
POETRY_VERSION: 1.8.5
144160
with:
145161
python-version: "${{ matrix.python-version }}"
146162
poetry-version: "${{ matrix.poetry-version }}"

diffsync/__init__.py

+15-14
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,33 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
"""
17+
1718
import sys
1819
from inspect import isclass
1920
from typing import (
21+
Any,
2022
Callable,
2123
ClassVar,
2224
Dict,
2325
List,
2426
Optional,
27+
Set,
2528
Tuple,
2629
Type,
2730
Union,
28-
Any,
29-
Set,
3031
)
31-
from typing_extensions import deprecated
3232

33-
from pydantic import ConfigDict, BaseModel, PrivateAttr
3433
import structlog # type: ignore
34+
from pydantic import BaseModel, ConfigDict, PrivateAttr
35+
from typing_extensions import deprecated
3536

3637
from diffsync.diff import Diff
37-
from diffsync.enum import DiffSyncModelFlags, DiffSyncFlags, DiffSyncStatus
38+
from diffsync.enum import DiffSyncFlags, DiffSyncModelFlags, DiffSyncStatus
3839
from diffsync.exceptions import (
3940
DiffClassMismatch,
4041
ObjectAlreadyExists,
41-
ObjectStoreWrongType,
4242
ObjectNotFound,
43+
ObjectStoreWrongType,
4344
)
4445
from diffsync.helpers import DiffSyncDiffer, DiffSyncSyncer
4546
from diffsync.store import BaseStore
@@ -69,7 +70,7 @@ class DiffSyncModel(BaseModel):
6970
be included in **at most** one of these three tuples.
7071
"""
7172

72-
_modelname: ClassVar[str] = "diffsyncmodel"
73+
_modelname: ClassVar[str] = "diffsyncmodel" # pylint: disable=used-before-assignment
7374
"""Name of this model, used by DiffSync to store and look up instances of this model or its equivalents.
7475
7576
Lowercase by convention; typically corresponds to the class name, but that is not enforced.
@@ -133,16 +134,16 @@ def __pydantic_init_subclass__(cls, **kwargs: Any) -> None:
133134
"""
134135
# Make sure that any field referenced by name actually exists on the model
135136
for attr in cls._identifiers:
136-
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
137138
raise AttributeError(f"_identifiers {cls._identifiers} references missing or un-annotated attr {attr}")
138139
for attr in cls._shortname:
139-
if attr not in cls.model_fields:
140+
if attr not in cls.model_fields: # pylint: disable=unsupported-membership-test
140141
raise AttributeError(f"_shortname {cls._shortname} references missing or un-annotated attr {attr}")
141142
for attr in cls._attributes:
142-
if attr not in cls.model_fields:
143+
if attr not in cls.model_fields: # pylint: disable=unsupported-membership-test
143144
raise AttributeError(f"_attributes {cls._attributes} references missing or un-annotated attr {attr}")
144145
for attr in cls._children.values():
145-
if attr not in cls.model_fields:
146+
if attr not in cls.model_fields: # pylint: disable=unsupported-membership-test
146147
raise AttributeError(f"_children {cls._children} references missing or un-annotated attr {attr}")
147148

148149
# Any given field can only be in one of (_identifiers, _attributes, _children)
@@ -431,7 +432,7 @@ class Adapter: # pylint: disable=too-many-public-methods
431432
# modelname1 = MyModelClass1
432433
# modelname2 = MyModelClass2
433434

434-
type: Optional[str] = None
435+
type: Optional[str] = None # pylint: disable=used-before-assignment
435436
"""Type of the object, will default to the name of the class if not provided."""
436437

437438
top_level: ClassVar[List[str]] = []
@@ -557,7 +558,7 @@ def load_from_dict(self, data: Dict) -> None:
557558
# Synchronization between DiffSync instances
558559
# ------------------------------------------------------------------------------
559560

560-
def sync_from( # pylint: disable=too-many-arguments
561+
def sync_from( # pylint: disable=too-many-arguments, too-many-positional-arguments
561562
self,
562563
source: "Adapter",
563564
diff_class: Type[Diff] = Diff,
@@ -601,7 +602,7 @@ def sync_from( # pylint: disable=too-many-arguments
601602

602603
return diff
603604

604-
def sync_to( # pylint: disable=too-many-arguments
605+
def sync_to( # pylint: disable=too-many-arguments, too-many-positional-arguments
605606
self,
606607
target: "Adapter",
607608
diff_class: Type[Diff] = Diff,

diffsync/diff.py

+5-6
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,8 +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():
109-
yield child
108+
yield from children.values()
110109

111110
def summary(self) -> Dict[StrType, int]:
112111
"""Build a dict summary of this Diff and its child DiffElements."""
@@ -161,7 +160,7 @@ def dict(self) -> Dict[StrType, Dict[StrType, Dict]]:
161160
class DiffElement: # pylint: disable=too-many-instance-attributes
162161
"""DiffElement object, designed to represent a single item/object that may or may not have any diffs."""
163162

164-
def __init__(
163+
def __init__( # pylint: disable=too-many-positional-arguments
165164
self,
166165
obj_type: StrType,
167166
name: StrType,

diffsync/exceptions.py

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
"""
17+
1718
from typing import TYPE_CHECKING, Union, Any
1819

1920
if TYPE_CHECKING:

diffsync/helpers.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
"""
17-
from collections.abc import Iterable as ABCIterable, Mapping as ABCMapping
18-
from typing import Callable, List, Optional, Tuple, Type, TYPE_CHECKING, Dict, Iterable
17+
18+
from collections.abc import Iterable as ABCIterable
19+
from collections.abc import Mapping as ABCMapping
20+
from typing import TYPE_CHECKING, Callable, Dict, Iterable, List, Optional, Tuple, Type
1921

2022
import structlog # type: ignore
2123

2224
from .diff import Diff, DiffElement
23-
from .enum import DiffSyncModelFlags, DiffSyncFlags, DiffSyncStatus, DiffSyncActions
24-
from .exceptions import ObjectNotFound, ObjectNotCreated, ObjectNotUpdated, ObjectNotDeleted, ObjectCrudException
25+
from .enum import DiffSyncActions, DiffSyncFlags, DiffSyncModelFlags, DiffSyncStatus
26+
from .exceptions import ObjectCrudException, ObjectNotCreated, ObjectNotDeleted, ObjectNotFound, ObjectNotUpdated
2527
from .utils import intersection, symmetric_difference
2628

2729
if TYPE_CHECKING: # pragma: no cover
@@ -35,7 +37,7 @@ class DiffSyncDiffer: # pylint: disable=too-many-instance-attributes
3537
Independent from Diff and DiffElement as those classes are purely data objects, while this stores some state.
3638
"""
3739

38-
def __init__( # pylint: disable=too-many-arguments
40+
def __init__( # pylint: disable=too-many-arguments, too-many-positional-arguments
3941
self,
4042
src_diffsync: "Adapter",
4143
dst_diffsync: "Adapter",
@@ -114,9 +116,9 @@ def diff_object_list(self, src: List["DiffSyncModel"], dst: List["DiffSyncModel"
114116

115117
combined_dict = {}
116118
for uid in dict_src:
117-
combined_dict[uid] = (dict_src.get(uid), dict_dst.get(uid))
119+
combined_dict[uid] = (dict_src.get(uid), dict_dst.get(uid)) # type: ignore
118120
for uid in dict_dst:
119-
combined_dict[uid] = (dict_src.get(uid), dict_dst.get(uid))
121+
combined_dict[uid] = (dict_src.get(uid), dict_dst.get(uid)) # type: ignore
120122
else:
121123
# In the future we might support set, etc...
122124
raise TypeError(f"Type combination {type(src)}/{type(dst)} is not supported... for now")
@@ -137,7 +139,7 @@ def diff_object_list(self, src: List["DiffSyncModel"], dst: List["DiffSyncModel"
137139

138140
@staticmethod
139141
def validate_objects_for_diff(
140-
object_pairs: Iterable[Tuple[Optional["DiffSyncModel"], Optional["DiffSyncModel"]]]
142+
object_pairs: Iterable[Tuple[Optional["DiffSyncModel"], Optional["DiffSyncModel"]]],
141143
) -> None:
142144
"""Check whether all DiffSyncModels in the given dictionary are valid for comparison to one another.
143145
@@ -285,7 +287,7 @@ class DiffSyncSyncer: # pylint: disable=too-many-instance-attributes
285287
Independent from DiffSync and DiffSyncModel as those classes are purely data objects, while this stores some state.
286288
"""
287289

288-
def __init__( # pylint: disable=too-many-arguments
290+
def __init__( # pylint: disable=too-many-arguments, too-many-positional-arguments
289291
self,
290292
diff: Diff,
291293
src_diffsync: "Adapter",

diffsync/store/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""BaseStore module."""
2+
23
from typing import Dict, List, Tuple, Type, Union, TYPE_CHECKING, Optional, Set, Any
34
import structlog # type: ignore
45

diffsync/store/redis.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"""RedisStore module."""
2+
23
import copy
34
import uuid
4-
from pickle import loads, dumps # nosec
5-
from typing import List, Type, Union, TYPE_CHECKING, Set, Any, Optional, Dict
5+
from pickle import dumps, loads # nosec
6+
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set, Type, Union
67

78
try:
89
from redis import Redis
@@ -11,7 +12,7 @@
1112
print("Redis is not installed. Have you installed diffsync with redis extra? `pip install diffsync[redis]`")
1213
raise ierr
1314

14-
from diffsync.exceptions import ObjectNotFound, ObjectStoreException, ObjectAlreadyExists
15+
from diffsync.exceptions import ObjectAlreadyExists, ObjectNotFound, ObjectStoreException
1516
from diffsync.store import BaseStore
1617

1718
if TYPE_CHECKING:
@@ -23,7 +24,7 @@
2324
class RedisStore(BaseStore):
2425
"""RedisStore class."""
2526

26-
def __init__(
27+
def __init__( # pylint: disable=too-many-arguments
2728
self,
2829
*args: Any,
2930
store_id: Optional[str] = None,
@@ -167,7 +168,7 @@ def add(self, *, obj: "DiffSyncModel") -> None:
167168

168169
existing_obj_binary = self._store.get(object_key)
169170
if existing_obj_binary:
170-
existing_obj = loads(existing_obj_binary)
171+
existing_obj = loads(existing_obj_binary) # nosec
171172
existing_obj_dict = existing_obj.dict()
172173

173174
if existing_obj_dict != obj.dict():

diffsync/utils.py

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
"""
17+
1718
from collections import OrderedDict
1819
from typing import Iterator, List, Dict, Optional, TypeVar, Callable, Generic
1920

examples/01-multiple-data-sources/models.py

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
"""
17+
1718
from typing import List, Optional
1819
from diffsync import DiffSyncModel
1920

examples/02-callback-function/main.py

+2-1
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):

0 commit comments

Comments
 (0)