oop-ext 2.0.0__tar.gz → 2.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. oop_ext-2.2.0/.github/dependabot.yml +13 -0
  2. oop_ext-2.2.0/.github/workflows/main.yml +87 -0
  3. {oop-ext-2.0.0 → oop_ext-2.2.0}/.gitignore +3 -0
  4. {oop-ext-2.0.0 → oop_ext-2.2.0}/.pre-commit-config.yaml +12 -5
  5. oop_ext-2.2.0/.readthedocs.yml +14 -0
  6. {oop-ext-2.0.0 → oop_ext-2.2.0}/CHANGELOG.rst +26 -3
  7. oop_ext-2.2.0/PKG-INFO +336 -0
  8. {oop-ext-2.0.0 → oop_ext-2.2.0}/README.rst +5 -2
  9. {oop-ext-2.0.0 → oop_ext-2.2.0}/docs/api.rst +1 -0
  10. {oop-ext-2.0.0 → oop_ext-2.2.0}/docs/callbacks.rst +7 -3
  11. {oop-ext-2.0.0 → oop_ext-2.2.0}/docs/conf.py +7 -8
  12. {oop-ext-2.0.0 → oop_ext-2.2.0}/docs/interfaces.rst +70 -2
  13. oop_ext-2.2.0/docs/requirements.txt +2 -0
  14. oop_ext-2.2.0/pyproject.toml +9 -0
  15. {oop-ext-2.0.0 → oop_ext-2.2.0}/setup.py +7 -10
  16. oop_ext-2.2.0/sonar-project.properties +6 -0
  17. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/_type_checker_fixture.py +10 -10
  18. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/conftest.py +1 -2
  19. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/_tests/test_cached_method.py +4 -7
  20. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/_tests/test_decorators.py +16 -11
  21. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/_tests/test_immutable.py +7 -7
  22. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/_tests/test_is_frozen.py +4 -6
  23. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/_tests/test_singleton.py +6 -7
  24. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/_tests/test_weak_ref.py +14 -16
  25. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/cached_method.py +15 -17
  26. oop_ext-2.2.0/src/oop_ext/foundation/callback/__init__.py +43 -0
  27. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/callback/_callback.py +28 -15
  28. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/callback/_callbacks.py +13 -5
  29. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/callback/_priority_callback.py +8 -3
  30. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/callback/_shortcuts.py +17 -15
  31. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/callback/_tests/test_callback.py +17 -11
  32. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/callback/_tests/test_priority_callback.py +8 -3
  33. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/callback/_tests/test_typed_callback.py +82 -2
  34. oop_ext-2.2.0/src/oop_ext/foundation/callback/_typed_callback.py +346 -0
  35. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/callback/single_call_callback.py +6 -3
  36. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/decorators.py +10 -4
  37. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/exceptions.py +1 -1
  38. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/immutable.py +15 -5
  39. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/is_frozen.py +1 -0
  40. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/odict.py +7 -3
  41. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/singleton.py +16 -10
  42. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/types_.py +6 -2
  43. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/weak_ref.py +26 -31
  44. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/interface/__init__.py +19 -20
  45. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/interface/_interface.py +96 -68
  46. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/interface/_tests/test_interface.py +119 -114
  47. oop_ext-2.2.0/src/oop_ext.egg-info/PKG-INFO +336 -0
  48. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext.egg-info/SOURCES.txt +4 -0
  49. oop_ext-2.2.0/tox.ini +14 -0
  50. oop-ext-2.0.0/.github/workflows/main.yml +0 -82
  51. oop-ext-2.0.0/.readthedocs.yml +0 -10
  52. oop-ext-2.0.0/PKG-INFO +0 -299
  53. oop-ext-2.0.0/src/oop_ext/foundation/callback/__init__.py +0 -28
  54. oop-ext-2.0.0/src/oop_ext/foundation/callback/_typed_callback.py +0 -207
  55. oop-ext-2.0.0/src/oop_ext.egg-info/PKG-INFO +0 -299
  56. oop-ext-2.0.0/tox.ini +0 -29
  57. {oop-ext-2.0.0 → oop_ext-2.2.0}/.codecov.yml +0 -0
  58. {oop-ext-2.0.0 → oop_ext-2.2.0}/.editorconfig +0 -0
  59. {oop-ext-2.0.0 → oop_ext-2.2.0}/.gitattributes +0 -0
  60. {oop-ext-2.0.0 → oop_ext-2.2.0}/.isort.cfg +0 -0
  61. {oop-ext-2.0.0 → oop_ext-2.2.0}/.project +0 -0
  62. {oop-ext-2.0.0 → oop_ext-2.2.0}/.pydevproject +0 -0
  63. {oop-ext-2.0.0 → oop_ext-2.2.0}/CONTRIBUTING.rst +0 -0
  64. {oop-ext-2.0.0 → oop_ext-2.2.0}/LICENSE +0 -0
  65. {oop-ext-2.0.0 → oop_ext-2.2.0}/docs/changelog.rst +0 -0
  66. {oop-ext-2.0.0 → oop_ext-2.2.0}/docs/contributing.rst +0 -0
  67. {oop-ext-2.0.0 → oop_ext-2.2.0}/docs/img/logo.png +0 -0
  68. {oop-ext-2.0.0 → oop_ext-2.2.0}/docs/index.rst +0 -0
  69. {oop-ext-2.0.0 → oop_ext-2.2.0}/docs/installation.rst +0 -0
  70. {oop-ext-2.0.0 → oop_ext-2.2.0}/docs/readme.rst +0 -0
  71. {oop-ext-2.0.0 → oop_ext-2.2.0}/environment.devenv.yml +0 -0
  72. {oop-ext-2.0.0 → oop_ext-2.2.0}/mypy.ini +0 -0
  73. {oop-ext-2.0.0 → oop_ext-2.2.0}/setup.cfg +0 -0
  74. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/__init__.py +0 -0
  75. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/__init__.py +0 -0
  76. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/_tests/__init__.py +0 -0
  77. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/_tests/test_odict.py +0 -0
  78. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/_tests/test_types.py +0 -0
  79. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/callback/_tests/__init__.py +0 -0
  80. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/callback/_tests/test_single_call_callback.py +0 -0
  81. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/foundation/compat.py +0 -0
  82. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/interface/_adaptable_interface.py +1 -1
  83. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/interface/_tests/__init__.py +0 -0
  84. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext/py.typed +0 -0
  85. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext.egg-info/dependency_links.txt +0 -0
  86. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext.egg-info/not-zip-safe +0 -0
  87. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext.egg-info/requires.txt +0 -0
  88. {oop-ext-2.0.0 → oop_ext-2.2.0}/src/oop_ext.egg-info/top_level.txt +0 -0
@@ -0,0 +1,13 @@
1
+ # Keep GitHub Actions up to date with GitHub's Dependabot...
2
+ # https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
3
+ # https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem
4
+ version: 2
5
+ updates:
6
+ - package-ecosystem: github-actions
7
+ directory: /
8
+ groups:
9
+ github-actions:
10
+ patterns:
11
+ - "*" # Group all Actions updates into a single larger pull request
12
+ schedule:
13
+ interval: weekly
@@ -0,0 +1,87 @@
1
+ name: build
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ tags:
8
+ - "v[0-9]+.[0-9]+.[0-9]+"
9
+
10
+ pull_request:
11
+
12
+ jobs:
13
+ build:
14
+
15
+ runs-on: ${{ matrix.os }}
16
+
17
+ strategy:
18
+ fail-fast: false
19
+ matrix:
20
+ python: ["3.10", "3.11", "3.12", "3.13"]
21
+ os: [ubuntu-latest, windows-latest]
22
+
23
+ steps:
24
+ - uses: actions/checkout@v4.2.1
25
+ - name: Set up Python
26
+ uses: actions/setup-python@v5.2.0
27
+ with:
28
+ python-version: ${{ matrix.python }}
29
+ - name: Install tox
30
+ run: |
31
+ python -m pip install --upgrade pip
32
+ pip install tox
33
+ - name: Test
34
+ run: |
35
+ tox -e py
36
+ - name: Upload coverage reports to Codecov
37
+ uses: codecov/codecov-action@v4.0.1
38
+ with:
39
+ token: ${{ secrets.CODECOV_TOKEN }}
40
+ fail_ci_if_error: true
41
+
42
+ deploy:
43
+
44
+ if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
45
+
46
+ runs-on: ubuntu-latest
47
+
48
+ needs: build
49
+
50
+ steps:
51
+ - uses: actions/checkout@v4.2.1
52
+ - name: Set up Python
53
+ uses: actions/setup-python@v5.2.0
54
+ with:
55
+ python-version: "3.x"
56
+ - name: Install wheel
57
+ run: |
58
+ python -m pip install --upgrade pip
59
+ pip install build
60
+ - name: Build package
61
+ run: |
62
+ python -m build
63
+ - name: Publish package to PyPI
64
+ uses: pypa/gh-action-pypi-publish@v1.10.3
65
+ with:
66
+ user: __token__
67
+ password: ${{ secrets.pypi_token }}
68
+ attestations: true
69
+ - name: GitHub Release
70
+ uses: softprops/action-gh-release@v2.0.8
71
+ with:
72
+ files: dist/*
73
+
74
+ sonarcloud:
75
+
76
+ runs-on: ubuntu-latest
77
+
78
+ steps:
79
+ - uses: actions/checkout@v4.2.1
80
+ with:
81
+ # Disabling shallow clone is recommended for improving relevancy of reporting
82
+ fetch-depth: 0
83
+ - name: SonarCloud Scan
84
+ uses: sonarsource/sonarcloud-github-action@master
85
+ env:
86
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
@@ -107,6 +107,9 @@ environment.yml
107
107
  .idea/
108
108
  .settings/
109
109
 
110
+ # VSCode local history
111
+ .history
112
+
110
113
  # mkdocs documentation
111
114
  /site
112
115
 
@@ -1,21 +1,27 @@
1
1
  repos:
2
2
  - repo: https://github.com/psf/black
3
- rev: 20.8b1
3
+ rev: 24.10.0
4
4
  hooks:
5
5
  - id: black
6
6
  args: [--safe, --quiet]
7
7
  language_version: python3
8
8
  - repo: https://github.com/asottile/blacken-docs
9
- rev: v1.10.0
9
+ rev: 1.19.0
10
10
  hooks:
11
11
  - id: blacken-docs
12
- additional_dependencies: [black==20.8b1]
12
+ additional_dependencies: [black==24.10.0]
13
13
  - repo: https://github.com/pre-commit/pre-commit-hooks
14
- rev: v3.4.0
14
+ rev: v5.0.0
15
15
  hooks:
16
16
  - id: trailing-whitespace
17
17
  - id: end-of-file-fixer
18
18
  - id: debug-statements
19
+ - repo: https://github.com/pycqa/isort
20
+ rev: 5.13.2
21
+ hooks:
22
+ - id: isort
23
+ name: isort
24
+ args: ["--force-single-line", "--line-length=100", "--profile=black"]
19
25
  - repo: local
20
26
  hooks:
21
27
  - id: rst
@@ -25,8 +31,9 @@ repos:
25
31
  language: python
26
32
  additional_dependencies: [pygments, restructuredtext_lint]
27
33
  - repo: https://github.com/pre-commit/mirrors-mypy
28
- rev: v0.812
34
+ rev: v1.12.1
29
35
  hooks:
30
36
  - id: mypy
31
37
  files: ^(src/)
32
38
  args: []
39
+ additional_dependencies: [types-attrs]
@@ -0,0 +1,14 @@
1
+ version: 2
2
+
3
+ build:
4
+ os: ubuntu-22.04
5
+ tools:
6
+ python: "3.11"
7
+
8
+ sphinx:
9
+ configuration: docs/conf.py
10
+
11
+ python:
12
+ install:
13
+ - path: .
14
+ - requirements: docs/requirements.txt
@@ -1,4 +1,28 @@
1
- 2.2.0 (2021-03-10)
1
+ 2.2.0
2
+ -----
3
+
4
+ **Release**: 2024-10-24
5
+
6
+ * ``PriorityCallback`` now has type checking support, similar to ``Callback``, with type checked variants: ``PriorityCallback0``, ``PriorityCallback1``, etc (`#128`_).
7
+ * ``UnregisterContext`` is now public, meant to be used in type annotations.
8
+ * Python 3.10+ is now required.
9
+
10
+ .. _#128: https://github.com/ESSS/oop-ext/pull/128
11
+
12
+ 2.1.0 (2021-03-19)
13
+ ------------------
14
+
15
+ * #48: New type-checker friendly ``proxy = GetProxy(I, obj)`` function as an alternative to ``proxy = I(obj)``. The
16
+ latter is not accepted by type checkers in general because interfaces are protocols, which can't be instantiated.
17
+
18
+ Also fixed a type-checking error with ``AsssertImplements``::
19
+
20
+ Only concrete class can be given where "Type[Interface]" is expected
21
+
22
+ This happens due to `python/mypy#5374 <https://github.com/python/mypy/issues/5374>`__.
23
+
24
+
25
+ 2.0.0 (2021-03-10)
2
26
  ------------------
3
27
 
4
28
  * #47: Interfaces no longer check type annotations at all.
@@ -58,8 +82,7 @@
58
82
  from oop_ext.foundation.callback import Callback2
59
83
 
60
84
 
61
- def changed(x: int, v: float) -> None:
62
- ...
85
+ def changed(x: int, v: float) -> None: ...
63
86
 
64
87
 
65
88
  on_changed = Callback2[int, float]()
oop_ext-2.2.0/PKG-INFO ADDED
@@ -0,0 +1,336 @@
1
+ Metadata-Version: 2.1
2
+ Name: oop-ext
3
+ Version: 2.2.0
4
+ Summary: OOP Extensions is a set of utilities for object oriented programming not found on Python's standard library.
5
+ Home-page: http://github.com/ESSS/oop-ext
6
+ Author: ESSS
7
+ Author-email: foss@esss.co
8
+ License: MIT license
9
+ Keywords: oop_ext
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Requires-Python: >=3.10
18
+ License-File: LICENSE
19
+ Requires-Dist: attrs
20
+ Provides-Extra: docs
21
+ Requires-Dist: sphinx>=1.4; extra == "docs"
22
+ Requires-Dist: sphinx_rtd_theme; extra == "docs"
23
+ Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
24
+ Provides-Extra: testing
25
+ Requires-Dist: codecov; extra == "testing"
26
+ Requires-Dist: pytest; extra == "testing"
27
+ Requires-Dist: pytest-cov; extra == "testing"
28
+ Requires-Dist: pytest-mock; extra == "testing"
29
+ Requires-Dist: pre-commit; extra == "testing"
30
+ Requires-Dist: tox; extra == "testing"
31
+ Requires-Dist: mypy; extra == "testing"
32
+
33
+ ======================================================================
34
+ OOP Extensions
35
+ ======================================================================
36
+
37
+ .. image:: https://img.shields.io/pypi/v/oop-ext.svg
38
+ :target: https://pypi.python.org/pypi/oop-ext
39
+
40
+ .. image:: https://img.shields.io/pypi/pyversions/oop-ext.svg
41
+ :target: https://pypi.org/project/oop-ext
42
+
43
+ .. image:: https://github.com/ESSS/oop-ext/workflows/build/badge.svg
44
+ :target: https://github.com/ESSS/oop-ext/actions
45
+
46
+ .. image:: https://codecov.io/gh/ESSS/oop-ext/branch/master/graph/badge.svg
47
+ :target: https://codecov.io/gh/ESSS/oop-ext
48
+
49
+ .. image:: https://img.shields.io/readthedocs/oop-extensions.svg
50
+ :target: https://oop-extensions.readthedocs.io/en/latest/
51
+
52
+ .. image:: https://results.pre-commit.ci/badge/github/ESSS/oop-ext/master.svg
53
+ :target: https://results.pre-commit.ci/latest/github/ESSS/oop-ext/master
54
+
55
+ .. image:: https://sonarcloud.io/api/project_badges/measure?project=ESSS_oop-ext&metric=alert_status
56
+ :target: https://sonarcloud.io/project/overview?id=ESSS_oop-ext
57
+
58
+
59
+ What is OOP Extensions ?
60
+ ================================================================================
61
+
62
+ OOP Extensions is a set of utilities for object oriented programming which is missing on Python core libraries.
63
+
64
+ Usage
65
+ ================================================================================
66
+ ``oop_ext`` brings a set of object oriented utilities, it supports the concept of interfaces,
67
+ abstract/overridable methods and more. ``oop_ext`` carefully checks that implementations
68
+ have the same method signatures as the interface it implements and raises exceptions otherwise.
69
+
70
+ Here's a simple example showing some nice features:
71
+
72
+ .. code-block:: python
73
+
74
+ from oop_ext.interface import Interface, ImplementsInterface
75
+
76
+
77
+ class IDisposable(Interface):
78
+ def dispose(self):
79
+ """
80
+ Clears this object
81
+ """
82
+
83
+ def is_disposed(self) -> bool:
84
+ """
85
+ Returns True if the object has been cleared
86
+ """
87
+
88
+
89
+ @ImplementsInterface(IDisposable)
90
+ class MyObject(Disposable):
91
+ def __init__(self):
92
+ super().__init__()
93
+ self._data = [0] * 100
94
+ self._is_disposed = False
95
+
96
+ def is_disposed(self) -> bool:
97
+ return self._is_disposed
98
+
99
+ def dispose(self):
100
+ self._is_disposed = True
101
+ self._data = []
102
+
103
+
104
+ If any of the two methods in ``MyObject`` are not implemented or have differ signatures than
105
+ the ones declared in ``IDisposable``, the ``ImplementsInterface`` decorator will raise an
106
+ error during import.
107
+
108
+ Arbitrary objects can be verified if they implement a certain interface by using ``IsImplementation``:
109
+
110
+ .. code-block:: python
111
+
112
+ from oop_ext.interface import IsImplementation
113
+
114
+ my_object = MyObject()
115
+ if IsImplementation(my_object, IDisposable):
116
+ # my_object is guaranteed to implement IDisposable completely
117
+ my_object.dispose()
118
+
119
+ Alternatively you can assert that an object implements the desired interface with ``AssertImplements``:
120
+
121
+ .. code-block:: python
122
+
123
+ from oop_ext.interface import AssertImplements
124
+
125
+ my_object = MyObject()
126
+ AssertImplements(my_object, IDisposable)
127
+ my_object.dispose()
128
+
129
+
130
+ Type Checking
131
+ -------------
132
+
133
+ As of ``1.1.0``, ``oop-ext`` includes inline type annotations and exposes them to user programs.
134
+
135
+ If you are running a type checker such as mypy on your tests, you may start noticing type errors indicating incorrect usage.
136
+ If you run into an error that you believe to be incorrect, please let us know in an issue.
137
+
138
+ The types were developed against ``mypy`` version 0.800.
139
+
140
+ See `the docs <https://oop-extensions.readthedocs.io/en/latest/interfaces.html#static-type-checking>`__
141
+ for more information.
142
+
143
+ Contributing
144
+ ------------
145
+
146
+ For guidance on setting up a development environment and how to make a
147
+ contribution to oop_ext, see the `contributing guidelines`_.
148
+
149
+ .. _contributing guidelines: https://github.com/ESSS/oop-ext/blob/master/CONTRIBUTING.rst
150
+
151
+
152
+ Release
153
+ -------
154
+ A reminder for the maintainers on how to make a new release.
155
+
156
+ Note that the VERSION should follow the semantic versioning as ``X.Y.Z`` (e.g. ``v1.0.5``).
157
+
158
+ 1. Create a ``release-VERSION`` branch from ``upstream/master``.
159
+ 2. Update ``CHANGELOG.rst``.
160
+ 3. Push a branch with the changes.
161
+ 4. Once all builds pass, push a ``VERSION`` tag to ``upstream``.
162
+ 5. Merge the PR.
163
+
164
+
165
+ 2.2.0
166
+ -----
167
+
168
+ **Release**: 2024-10-24
169
+
170
+ * ``PriorityCallback`` now has type checking support, similar to ``Callback``, with type checked variants: ``PriorityCallback0``, ``PriorityCallback1``, etc (`#128`_).
171
+ * ``UnregisterContext`` is now public, meant to be used in type annotations.
172
+ * Python 3.10+ is now required.
173
+
174
+ .. _#128: https://github.com/ESSS/oop-ext/pull/128
175
+
176
+ 2.1.0 (2021-03-19)
177
+ ------------------
178
+
179
+ * #48: New type-checker friendly ``proxy = GetProxy(I, obj)`` function as an alternative to ``proxy = I(obj)``. The
180
+ latter is not accepted by type checkers in general because interfaces are protocols, which can't be instantiated.
181
+
182
+ Also fixed a type-checking error with ``AsssertImplements``::
183
+
184
+ Only concrete class can be given where "Type[Interface]" is expected
185
+
186
+ This happens due to `python/mypy#5374 <https://github.com/python/mypy/issues/5374>`__.
187
+
188
+
189
+ 2.0.0 (2021-03-10)
190
+ ------------------
191
+
192
+ * #47: Interfaces no longer check type annotations at all.
193
+
194
+ It was supported initially, but in practice
195
+ this feature has shown up to be an impediment to adopting type annotations incrementally, as it
196
+ discourages adding type annotations to improve existing interfaces, or annotating
197
+ existing implementations without having to update the interface (and all other implementations
198
+ by consequence).
199
+
200
+ It was decided to let the static type checker correctly deal with matching type annotations, as
201
+ it can do so more accurately than ``oop-ext`` did before.
202
+
203
+ 1.2.0 (2021-03-09)
204
+ ------------------
205
+
206
+ * #43: Fix support for type annotated ``Attribute`` and ``ReadOnlyAttribute``:
207
+
208
+ .. code-block:: python
209
+
210
+ class IFoo(Interface):
211
+ value: int = Attribute(int)
212
+
213
+ 1.1.2 (2021-02-23)
214
+ ------------------
215
+
216
+ * #41: Fix regression introduced in ``1.1.0`` where installing a callback using
217
+ ``callback.After`` or ``callback.Before`` would make a method no longer compliant with
218
+ the signature required by its interface.
219
+
220
+ 1.1.1 (2021-02-23)
221
+ ------------------
222
+
223
+ * #38: Reintroduce ``extra_args`` argument to ``Callback._GetKey``, so subclasses can make use
224
+ of it.
225
+
226
+ * #36: Fix regression introduced in ``1.1.0`` where ``Abstract`` and ``Implements`` decorators
227
+ could no longer be used in interfaces implementations.
228
+
229
+ 1.1.0 (2021-02-19)
230
+ ------------------
231
+
232
+ * #25: ``oop-ext`` now includes inline type annotations and exposes them to user programs.
233
+
234
+ If you are running a type checker such as mypy on your tests, you may start noticing type errors indicating incorrect usage.
235
+ If you run into an error that you believe to be incorrect, please let us know in an issue.
236
+
237
+ The types were developed against ``mypy`` version 0.800.
238
+
239
+ * #26: New type-checked ``Callback`` variants, ``Callback0``, ``Callback1``, ``Callback2``, etc, providing
240
+ type checking for all operations(calling, ``Register``, etc) at nearly zero runtime cost.
241
+
242
+ Example:
243
+
244
+ .. code-block:: python
245
+
246
+ from oop_ext.foundation.callback import Callback2
247
+
248
+
249
+ def changed(x: int, v: float) -> None: ...
250
+
251
+
252
+ on_changed = Callback2[int, float]()
253
+ on_changed(10, 5.25)
254
+
255
+
256
+ * Fixed ``Callbacks.Before`` and ``Callbacks.After`` signatures: previously their signature conveyed
257
+ that they supported multiple callbacks, but it was a mistake which would break callers because
258
+ every parameter after the 2nd would be considered the ``sender_as_parameter`` parameter, which
259
+ was forwarded to ``After`` and ``Before`` functions of the ``_shortcuts.py``
260
+ module.
261
+
262
+ 1.0.0 (2020-10-01)
263
+ ------------------
264
+
265
+ * ``Callbacks`` can be used as context manager, which provides a ``Register(callback, function)``,
266
+ which automatically unregisters all functions when the context manager ends.
267
+
268
+ * ``Callback.Register(function)`` now returns an object with a ``Unregister()`` method, which
269
+ can be used to undo the register call.
270
+
271
+ 0.6.0 (2020-01-31)
272
+ ==================
273
+
274
+ * Change back the default value of ``requires_declaration`` to ``True`` and fix an error (#22) where the cache wasn't properly cleared.
275
+
276
+ 0.5.1 (2019-12-20)
277
+ ------------------
278
+
279
+ * Fixes an issue (#20) where mocked `classmethods` weren't considered a valid method during internal checks.
280
+
281
+ 0.5.0 (2019-12-12)
282
+ ------------------
283
+
284
+ * Add optional argument ``requires_declaration`` so users can decide whether or not ``@ImplementsInterface`` declarations are necessary.
285
+
286
+ 0.4.0 (2019-12-03)
287
+ ------------------
288
+
289
+ * Implementations no longer need to explicitly declare that they declare an interface with ``@ImplementsInterface``: the check is done implicitly (and cached) by `AssertImplements` and equivalent functions.
290
+
291
+ 0.3.2 (2019-08-22)
292
+ ------------------
293
+
294
+ * Interface and implementation methods can no longer contain mutable defaults, as this is considered
295
+ a bad practice in general.
296
+
297
+ * ``Null`` instances are now hashable.
298
+
299
+
300
+ 0.3.1 (2019-08-16)
301
+ ------------------
302
+
303
+ * Fix mismatching signatures when creating "interface stubs" for instances:
304
+
305
+ .. code-block:: python
306
+
307
+ foo = IFoo(Foo())
308
+
309
+
310
+ 0.3.0 (2019-08-08)
311
+ ------------------
312
+
313
+ * Interfaces now support keyword-only arguments.
314
+
315
+ 0.2.4 (2019-03-22)
316
+ ------------------
317
+
318
+ * Remove ``FunctionNotRegisteredError`` exception, which has not been in use for a few years.
319
+
320
+
321
+ 0.2.3 (2019-03-22)
322
+ ------------------
323
+
324
+ * Fix issues of ignored exception on nested callback.
325
+
326
+
327
+ 0.2.1 (2019-03-14)
328
+ ------------------
329
+
330
+ * Fix issues and remove obsolete code.
331
+
332
+
333
+ 0.1.8 (2019-03-12)
334
+ ------------------
335
+
336
+ * First release on PyPI.
@@ -20,6 +20,10 @@ OOP Extensions
20
20
  .. image:: https://results.pre-commit.ci/badge/github/ESSS/oop-ext/master.svg
21
21
  :target: https://results.pre-commit.ci/latest/github/ESSS/oop-ext/master
22
22
 
23
+ .. image:: https://sonarcloud.io/api/project_badges/measure?project=ESSS_oop-ext&metric=alert_status
24
+ :target: https://sonarcloud.io/project/overview?id=ESSS_oop-ext
25
+
26
+
23
27
  What is OOP Extensions ?
24
28
  ================================================================================
25
29
 
@@ -117,8 +121,7 @@ Release
117
121
  -------
118
122
  A reminder for the maintainers on how to make a new release.
119
123
 
120
- Note that the VERSION should follow the semantic versioning as X.Y.Z
121
- Ex.: v1.0.5
124
+ Note that the VERSION should follow the semantic versioning as ``X.Y.Z`` (e.g. ``v1.0.5``).
122
125
 
123
126
  1. Create a ``release-VERSION`` branch from ``upstream/master``.
124
127
  2. Update ``CHANGELOG.rst``.
@@ -20,3 +20,4 @@ API Reference
20
20
  :members:
21
21
 
22
22
  .. autofunction:: ImplementsInterface
23
+ .. autofunction:: GetProxy
@@ -45,7 +45,11 @@ type checked for number of arguments and types.
45
45
  The method specialized signatures are only seen by the type checker, so using one of the specialized
46
46
  variants should have nearly zero runtime cost (only the cost of an empty subclass).
47
47
 
48
+ .. versionadded:: 2.2.0
49
+
50
+ ``PriorityCallback`` has the same support, with ``PriorityCallback0``, ``PriorityCallback1``, ``PriorityCallback2``, etc.
51
+
48
52
  .. note::
49
- The separate callback classes are needed for now, but if/when
50
- `pep-0646 <https://www.python.org/dev/peps/pep-0646>`__ lands, we should be able to
51
- implement the generic variants into ``Callback`` itself.
53
+ The separate callback classes are needed for now, but once we require Python 3.11
54
+ (`pep-0646 <https://www.python.org/dev/peps/pep-0646>`__, we should be able to
55
+ implement the generic variants into ``Callback`` and ``PriorityCallback`` themselves.
@@ -12,7 +12,6 @@
12
12
  #
13
13
  # All configuration values have a default; values that are commented out
14
14
  # serve to show the default.
15
-
16
15
  # If extensions (or modules to document with autodoc) are in another
17
16
  # directory, add these directories to sys.path here. If the directory is
18
17
  # relative to the documentation root, use os.path.abspath to make it
@@ -47,9 +46,9 @@ source_suffix = ".rst"
47
46
  master_doc = "index"
48
47
 
49
48
  # General information about the project.
50
- project = u"Oop_ext"
51
- copyright = u"2018, ESSS"
52
- author = u"ESSS"
49
+ project = "Oop_ext"
50
+ copyright = "2018, ESSS"
51
+ author = "ESSS"
53
52
 
54
53
  # The version info for the project you're documenting, acts as replacement
55
54
  # for |version| and |release|, also used in various other places throughout
@@ -66,7 +65,7 @@ author = u"ESSS"
66
65
  #
67
66
  # This is also used if you do content translation via gettext catalogs.
68
67
  # Usually you set "language" from the command line for these cases.
69
- language = None
68
+ language = "en"
70
69
 
71
70
  # List of patterns, relative to source directory, that match files and
72
71
  # directories to ignore when looking for source files.
@@ -127,7 +126,7 @@ latex_elements = {
127
126
  # (source start file, target name, title, author, documentclass
128
127
  # [howto, manual, or own class]).
129
128
  latex_documents = [
130
- (master_doc, "oop_ext.tex", u"Oop_ext Documentation", u"ESSS", "manual")
129
+ (master_doc, "oop_ext.tex", "Oop_ext Documentation", "ESSS", "manual")
131
130
  ]
132
131
 
133
132
 
@@ -135,7 +134,7 @@ latex_documents = [
135
134
 
136
135
  # One entry per manual page. List of tuples
137
136
  # (source start file, name, description, authors, manual section).
138
- man_pages = [(master_doc, "oop_ext", u"Oop_ext Documentation", [author], 1)]
137
+ man_pages = [(master_doc, "oop_ext", "Oop_ext Documentation", [author], 1)]
139
138
 
140
139
 
141
140
  # -- Options for Texinfo output ----------------------------------------
@@ -147,7 +146,7 @@ texinfo_documents = [
147
146
  (
148
147
  master_doc,
149
148
  "oop_ext",
150
- u"Oop_ext Documentation",
149
+ "Oop_ext Documentation",
151
150
  author,
152
151
  "oop_ext",
153
152
  "One line description of project.",