diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index c5a6404..de22a3a 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -1,26 +1,26 @@ -name: pre-commit - -on: - push: - branches: - - master - - pull_request: - branches: - - master - -jobs: - pre-commit: - runs-on: ubuntu-latest - - steps: - - name: Checkout Repo - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - - name: Run pre-commit - uses: pre-commit/action@v3.0.1 +name: pre-commit + +on: + push: + branches: + - master + + pull_request: + branches: + - master + +jobs: + pre-commit: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + + - name: Run pre-commit + uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 39023a9..0cef101 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,17 +1,19 @@ repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 - hooks: - - id: check-toml - - id: trailing-whitespace + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-toml + - id: check-yaml -- repo: https://github.com/psf/black - rev: 24.8.0 - hooks: - - id: black - language_version: python3.10 + - repo: https://github.com/psf/black + rev: 24.8.0 + hooks: + - id: black + language_version: python3.10 -- repo: https://github.com/pycqa/isort - rev: 5.13.2 - hooks: - - id: isort + - repo: https://github.com/pycqa/isort + rev: 5.13.2 + hooks: + - id: isort diff --git a/pure_interface/__init__.py b/pure_interface/__init__.py index 2b9dada..c07f2f6 100644 --- a/pure_interface/__init__.py +++ b/pure_interface/__init__.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + from ._sub_interface import sub_interface_of from .adaption import AdapterTracker, adapt_args, adapts, register_adapter from .delegation import Delegate @@ -15,4 +19,4 @@ type_is_interface, ) -__version__ = "8.0.2" +__version__ = "8.0.3" # Don't change this manually - run `bump-my-version bump [major|minor|patch]` instead diff --git a/pure_interface/_sub_interface.py b/pure_interface/_sub_interface.py index cd5d274..96faf6c 100644 --- a/pure_interface/_sub_interface.py +++ b/pure_interface/_sub_interface.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + """ decorator function for sub-interfaces A sub-interface is a non-empty subset of another, larger, interface. diff --git a/pure_interface/adaption.py b/pure_interface/adaption.py index d0008bd..986372f 100644 --- a/pure_interface/adaption.py +++ b/pure_interface/adaption.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + from __future__ import absolute_import, division, print_function import functools diff --git a/pure_interface/delegation.py b/pure_interface/delegation.py index c0ec3be..cc438cb 100644 --- a/pure_interface/delegation.py +++ b/pure_interface/delegation.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + from __future__ import absolute_import, division, print_function import operator diff --git a/pure_interface/errors.py b/pure_interface/errors.py index e737a85..279ffb4 100644 --- a/pure_interface/errors.py +++ b/pure_interface/errors.py @@ -1,3 +1,8 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + + class PureInterfaceError(Exception): """All exceptions raised by this module are subclasses of this exception""" diff --git a/pure_interface/interface.py b/pure_interface/interface.py index a21b188..f97114a 100644 --- a/pure_interface/interface.py +++ b/pure_interface/interface.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + """ pure_interface enforces empty functions and properties on interfaces and provides adaption and structural type checking. """ diff --git a/pure_interface/mypy_plugin.py b/pure_interface/mypy_plugin.py index 6780acc..db83e97 100644 --- a/pure_interface/mypy_plugin.py +++ b/pure_interface/mypy_plugin.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + from collections.abc import Callable from typing import Dict, Final, List, Optional, TypeAlias, cast diff --git a/pyproject.toml b/pyproject.toml index 054ef09..fe8795e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "pure-interface" -dynamic = ["version"] +version = "8.0.3" description = "A Python interface library that disallows function body content on interfaces and supports adaption." keywords = ["interface", "protocol", "adaption", "structural", "dataclass"] authors = [ @@ -33,9 +33,6 @@ typing = ['mypy'] requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" -[tool.setuptools.dynamic] -version = {attr = "pure_interface.__version__"} - [tool.mypy] plugins = "pure_interface/mypy_plugin.py" @@ -44,3 +41,33 @@ line-length = 120 [tool.isort] profile = "black" + +[tool.bumpversion] +current_version = "8.0.3" +parse = "(?P\\d+)\\.(?P\\d+)\\.(?P\\d+)" +serialize = ["{major}.{minor}.{patch}"] +search = "{current_version}" +replace = "{new_version}" +regex = false +ignore_missing_version = false +ignore_missing_files = false +tag = true +sign_tags = false +tag_name = "v{new_version}" +tag_message = "Bump version: {current_version} → {new_version}" +allow_dirty = false +commit = true +message = "Bump version: {current_version} → {new_version}" +setup_hooks = [] +pre_commit_hooks = [] +post_commit_hooks = [] + +[[tool.bumpversion.files]] +filename = "pyproject.toml" +search = 'version = "{current_version}"' +replace = 'version = "{new_version}"' + +[[tool.bumpversion.files]] +filename = "pure_interface/__init__.py" +search = '__version__ = "{current_version}"' +replace = '__version__ = "{new_version}"' diff --git a/requirements_dev.txt b/requirements_dev.txt index 3d64b3b..7d3eacb 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,2 +1,3 @@ --r requirements.txt +bump-my-version==0.26.0 mypy +pre-commit==3.8.0 diff --git a/tests/__init__.py b/tests/__init__.py index 12be00c..a015be1 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + import warnings warnings.filterwarnings("ignore", category=UserWarning) diff --git a/tests/interface_module.py b/tests/interface_module.py index 3bd19c4..f7c7cc7 100644 --- a/tests/interface_module.py +++ b/tests/interface_module.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + import pure_interface diff --git a/tests/mypy_source.py b/tests/mypy_source.py index 61c75dc..1858579 100644 --- a/tests/mypy_source.py +++ b/tests/mypy_source.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + """With the pure-interface mypy plugin enabled, mypy should validate this file without error. This is working except for dataclasses __init__ call arguments. diff --git a/tests/temp.py b/tests/temp.py index f60a055..c3314d9 100644 --- a/tests/temp.py +++ b/tests/temp.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + import dataclasses import pure_interface diff --git a/tests/test_adapt_args_anno.py b/tests/test_adapt_args_anno.py index fbfb70f..d575fe5 100644 --- a/tests/test_adapt_args_anno.py +++ b/tests/test_adapt_args_anno.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + import unittest try: diff --git a/tests/test_adapt_args_no_anno.py b/tests/test_adapt_args_no_anno.py index 7933c47..7703f41 100644 --- a/tests/test_adapt_args_no_anno.py +++ b/tests/test_adapt_args_no_anno.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + import unittest import pure_interface.errors diff --git a/tests/test_adaption.py b/tests/test_adaption.py index f142489..91228f7 100644 --- a/tests/test_adaption.py +++ b/tests/test_adaption.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + import unittest import warnings from unittest import mock diff --git a/tests/test_dataclass_support.py b/tests/test_dataclass_support.py index 5f54515..ad2be79 100644 --- a/tests/test_dataclass_support.py +++ b/tests/test_dataclass_support.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + import unittest from dataclasses import dataclass diff --git a/tests/test_delegate.py b/tests/test_delegate.py index 683b32b..685812d 100644 --- a/tests/test_delegate.py +++ b/tests/test_delegate.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + import dataclasses import unittest from unittest import mock diff --git a/tests/test_func_sigs3.py b/tests/test_func_sigs3.py index cd14933..d679981 100644 --- a/tests/test_func_sigs3.py +++ b/tests/test_func_sigs3.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + import types import unittest diff --git a/tests/test_func_sigs_po.py b/tests/test_func_sigs_po.py index 955e08a..f714b7c 100644 --- a/tests/test_func_sigs_po.py +++ b/tests/test_func_sigs_po.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + # -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals diff --git a/tests/test_function_sigs.py b/tests/test_function_sigs.py index 7c8c96f..07ec685 100644 --- a/tests/test_function_sigs.py +++ b/tests/test_function_sigs.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + import types import unittest diff --git a/tests/test_generic_support.py b/tests/test_generic_support.py index 2cbe740..4cd1ce8 100644 --- a/tests/test_generic_support.py +++ b/tests/test_generic_support.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + import unittest from typing import Iterable, List, TypeVar diff --git a/tests/test_implementation_checks.py b/tests/test_implementation_checks.py index 16d86b5..d164af1 100644 --- a/tests/test_implementation_checks.py +++ b/tests/test_implementation_checks.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + import abc import unittest import warnings diff --git a/tests/test_inheritance.py b/tests/test_inheritance.py index 1c69a05..69c85f0 100644 --- a/tests/test_inheritance.py +++ b/tests/test_inheritance.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + import unittest import pure_interface diff --git a/tests/test_isinstance.py b/tests/test_isinstance.py index 36c5589..7cdec34 100644 --- a/tests/test_isinstance.py +++ b/tests/test_isinstance.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + import io import unittest import warnings diff --git a/tests/test_meta_classes.py b/tests/test_meta_classes.py index 5fb2e5b..fb6fc7b 100644 --- a/tests/test_meta_classes.py +++ b/tests/test_meta_classes.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + import abc import unittest diff --git a/tests/test_module_funcs.py b/tests/test_module_funcs.py index f44705b..09ae471 100644 --- a/tests/test_module_funcs.py +++ b/tests/test_module_funcs.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + import unittest from pure_interface import * diff --git a/tests/test_no_content_checks.py b/tests/test_no_content_checks.py index eb82a69..9a42489 100644 --- a/tests/test_no_content_checks.py +++ b/tests/test_no_content_checks.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + import abc import unittest diff --git a/tests/test_singledispatch.py b/tests/test_singledispatch.py index 9ae0013..787e8f2 100644 --- a/tests/test_singledispatch.py +++ b/tests/test_singledispatch.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + import unittest from functools import singledispatchmethod from typing import Any diff --git a/tests/test_sub_interfaces.py b/tests/test_sub_interfaces.py index 4a76563..2ab521d 100644 --- a/tests/test_sub_interfaces.py +++ b/tests/test_sub_interfaces.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + import dataclasses import unittest diff --git a/tests/test_tracker.py b/tests/test_tracker.py index 7eadc57..67a8903 100644 --- a/tests/test_tracker.py +++ b/tests/test_tracker.py @@ -1,3 +1,7 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved. +# -------------------------------------------------------------------------------------------- + import unittest from pure_interface import *