Skip to content

Release v2.1.0 #290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 40 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on: # yamllint disable
pull_request: ~
jobs:
validate_renovate:
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-24.04"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v2"
Expand All @@ -22,88 +22,102 @@ jobs:
with:
pattern: "renovate.json"
black:
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-24.04"
env:
INVOKE_LOCAL: "True"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v2"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v5"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.5"
- name: "Linting: black"
run: "poetry run invoke black"
bandit:
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-24.04"
env:
INVOKE_LOCAL: "True"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v2"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v5"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.5"
- name: "Linting: bandit"
run: "poetry run invoke bandit"
needs:
- "black"
pydocstyle:
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-24.04"
env:
INVOKE_LOCAL: "True"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v2"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v5"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.5"
- name: "Linting: pydocstyle"
run: "poetry run invoke pydocstyle"
needs:
- "black"
flake8:
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-24.04"
env:
INVOKE_LOCAL: "True"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v2"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v5"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.5"
- name: "Linting: flake8"
run: "poetry run invoke flake8"
needs:
- "black"
mypy:
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-24.04"
env:
INVOKE_LOCAL: "True"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v2"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v5"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.5"
- name: "Linting: mypy"
run: "poetry run invoke mypy"
needs:
- "black"
yamllint:
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-24.04"
env:
INVOKE_LOCAL: "True"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v2"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v5"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.5"
- name: "Linting: yamllint"
run: "poetry run invoke yamllint"
needs:
- "black"
build:
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-24.04"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v2"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v5"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.5"
- name: "Build Container"
run: "poetry run invoke build"
needs:
Expand All @@ -113,12 +127,14 @@ jobs:
- "yamllint"
- "mypy"
pylint:
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-24.04"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v2"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v5"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.5"
- name: "Build Container"
run: "poetry run invoke build"
- name: "Linting: Pylint"
Expand All @@ -129,9 +145,9 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
poetry-version: ["1.5.1"]
runs-on: "ubuntu-20.04"
python-version: ["3.9", "3.10", "3.11"]
poetry-version: ["1.8.5"]
runs-on: "ubuntu-24.04"
env:
PYTHON_VER: "${{ matrix.python-version }}"
steps:
Expand All @@ -140,7 +156,7 @@ jobs:
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@3ea5d3ecf382cdcb0c74d4c0ff0629d95fce63c7"
env:
POETRY_VERSION: 1.5.1
POETRY_VERSION: 1.8.5
with:
python-version: "${{ matrix.python-version }}"
poetry-version: "${{ matrix.poetry-version }}"
Expand All @@ -154,7 +170,7 @@ jobs:
- "pylint"
publish_gh:
name: "Publish to GitHub"
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-24.04"
if: "startsWith(github.ref, 'refs/tags/v')"
steps:
- name: "Check out repository code"
Expand Down Expand Up @@ -183,7 +199,7 @@ jobs:
- "unittest"
publish_pypi:
name: "Push Package to PyPI"
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-24.04"
if: "startsWith(github.ref, 'refs/tags/v')"
steps:
- name: "Check out repository code"
Expand Down Expand Up @@ -212,7 +228,7 @@ jobs:
- "publish_gh"
- "publish_pypi"
name: "Send notification to the Slack"
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-24.04"
env:
SLACK_WEBHOOK_URL: "${{ secrets.SLACK_WEBHOOK_URL }}"
SLACK_MESSAGE: >-
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [2.1.0]

### Changed

- [284](https://github.com/networktocode/diffsync/pull/284) - Update pyyaml to 6.0.2 in poetry.lock by @gsnider2195
- [286](https://github.com/networktocode/diffsync/pull/286) - Update GitHub Actions runner version by @mjbear
- [289](https://github.com/networktocode/diffsync/pull/289) - Remove upper limit on Packaging by @jdrew82

## New Contributors

- @gsnider2195 made their first contribution in https://github.com/networktocode/diffsync/pull/284
- @mjbear made their first contribution in https://github.com/networktocode/diffsync/pull/286
- @jdrew82 made their first contribution in https://github.com/networktocode/diffsync/pull/289

## [2.0.1]

### Changed
Expand Down
29 changes: 15 additions & 14 deletions diffsync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,33 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

import sys
from inspect import isclass
from typing import (
Any,
Callable,
ClassVar,
Dict,
List,
Optional,
Set,
Tuple,
Type,
Union,
Any,
Set,
)
from typing_extensions import deprecated

from pydantic import ConfigDict, BaseModel, PrivateAttr
import structlog # type: ignore
from pydantic import BaseModel, ConfigDict, PrivateAttr
from typing_extensions import deprecated

from diffsync.diff import Diff
from diffsync.enum import DiffSyncModelFlags, DiffSyncFlags, DiffSyncStatus
from diffsync.enum import DiffSyncFlags, DiffSyncModelFlags, DiffSyncStatus
from diffsync.exceptions import (
DiffClassMismatch,
ObjectAlreadyExists,
ObjectStoreWrongType,
ObjectNotFound,
ObjectStoreWrongType,
)
from diffsync.helpers import DiffSyncDiffer, DiffSyncSyncer
from diffsync.store import BaseStore
Expand Down Expand Up @@ -69,7 +70,7 @@ class DiffSyncModel(BaseModel):
be included in **at most** one of these three tuples.
"""

_modelname: ClassVar[str] = "diffsyncmodel"
_modelname: ClassVar[str] = "diffsyncmodel" # pylint: disable=used-before-assignment
"""Name of this model, used by DiffSync to store and look up instances of this model or its equivalents.

Lowercase by convention; typically corresponds to the class name, but that is not enforced.
Expand Down Expand Up @@ -133,16 +134,16 @@ def __pydantic_init_subclass__(cls, **kwargs: Any) -> None:
"""
# Make sure that any field referenced by name actually exists on the model
for attr in cls._identifiers:
if attr not in cls.model_fields and not hasattr(cls, attr):
if attr not in cls.model_fields and not hasattr(cls, attr): # pylint: disable=unsupported-membership-test
raise AttributeError(f"_identifiers {cls._identifiers} references missing or un-annotated attr {attr}")
for attr in cls._shortname:
if attr not in cls.model_fields:
if attr not in cls.model_fields: # pylint: disable=unsupported-membership-test
raise AttributeError(f"_shortname {cls._shortname} references missing or un-annotated attr {attr}")
for attr in cls._attributes:
if attr not in cls.model_fields:
if attr not in cls.model_fields: # pylint: disable=unsupported-membership-test
raise AttributeError(f"_attributes {cls._attributes} references missing or un-annotated attr {attr}")
for attr in cls._children.values():
if attr not in cls.model_fields:
if attr not in cls.model_fields: # pylint: disable=unsupported-membership-test
raise AttributeError(f"_children {cls._children} references missing or un-annotated attr {attr}")

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

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

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

def sync_from( # pylint: disable=too-many-arguments
def sync_from( # pylint: disable=too-many-arguments, too-many-positional-arguments
self,
source: "Adapter",
diff_class: Type[Diff] = Diff,
Expand Down Expand Up @@ -601,7 +602,7 @@ def sync_from( # pylint: disable=too-many-arguments

return diff

def sync_to( # pylint: disable=too-many-arguments
def sync_to( # pylint: disable=too-many-arguments, too-many-positional-arguments
self,
target: "Adapter",
diff_class: Type[Diff] = Diff,
Expand Down
11 changes: 5 additions & 6 deletions diffsync/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"""

from functools import total_ordering
from typing import Any, Iterator, Optional, Type, List, Dict, Iterable
from typing import Any, Dict, Iterable, Iterator, List, Optional, Type

from .exceptions import ObjectAlreadyExists
from .utils import intersection, OrderedDefaultDict
from .enum import DiffSyncActions
from .exceptions import ObjectAlreadyExists
from .utils import OrderedDefaultDict, intersection

# This workaround is used because we are defining a method called `str` in our class definition, which therefore renders
# the builtin `str` type unusable.
Expand Down Expand Up @@ -105,8 +105,7 @@ def order_children_default(cls, children: Dict[StrType, "DiffElement"]) -> Itera

Since children is already an OrderedDefaultDict, this method is not doing anything special.
"""
for child in children.values():
yield child
yield from children.values()

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

def __init__(
def __init__( # pylint: disable=too-many-positional-arguments
self,
obj_type: StrType,
name: StrType,
Expand Down
1 change: 1 addition & 0 deletions diffsync/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

from typing import TYPE_CHECKING, Union, Any

if TYPE_CHECKING:
Expand Down
Loading