oop-ext 2.1.0__tar.gz → 2.3.1__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 (90) hide show
  1. oop_ext-2.3.1/.github/dependabot.yml +13 -0
  2. oop_ext-2.3.1/.github/workflows/deploy.yml +57 -0
  3. oop_ext-2.3.1/.github/workflows/test.yml +79 -0
  4. {oop-ext-2.1.0 → oop_ext-2.3.1}/.gitignore +3 -0
  5. {oop-ext-2.1.0 → oop_ext-2.3.1}/.pre-commit-config.yaml +12 -5
  6. oop_ext-2.3.1/.readthedocs.yml +14 -0
  7. {oop-ext-2.1.0 → oop_ext-2.3.1}/CHANGELOG.rst +28 -2
  8. oop_ext-2.3.1/PKG-INFO +369 -0
  9. {oop-ext-2.1.0 → oop_ext-2.3.1}/README.rst +10 -4
  10. {oop-ext-2.1.0 → oop_ext-2.3.1}/docs/callbacks.rst +7 -3
  11. {oop-ext-2.1.0 → oop_ext-2.3.1}/docs/conf.py +7 -8
  12. oop_ext-2.3.1/docs/requirements.txt +2 -0
  13. oop_ext-2.3.1/pyproject.toml +8 -0
  14. {oop-ext-2.1.0 → oop_ext-2.3.1}/setup.py +8 -10
  15. oop_ext-2.3.1/sonar-project.properties +6 -0
  16. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/_type_checker_fixture.py +10 -10
  17. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/conftest.py +1 -2
  18. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/_tests/test_cached_method.py +4 -7
  19. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/_tests/test_decorators.py +16 -11
  20. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/_tests/test_immutable.py +7 -7
  21. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/_tests/test_is_frozen.py +4 -6
  22. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/_tests/test_singleton.py +6 -7
  23. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/_tests/test_weak_ref.py +19 -21
  24. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/cached_method.py +15 -17
  25. oop_ext-2.3.1/src/oop_ext/foundation/callback/__init__.py +43 -0
  26. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/callback/_callback.py +28 -15
  27. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/callback/_callbacks.py +13 -5
  28. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/callback/_priority_callback.py +8 -3
  29. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/callback/_shortcuts.py +17 -15
  30. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/callback/_tests/test_callback.py +17 -11
  31. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/callback/_tests/test_priority_callback.py +8 -3
  32. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/callback/_tests/test_typed_callback.py +82 -2
  33. oop_ext-2.3.1/src/oop_ext/foundation/callback/_typed_callback.py +346 -0
  34. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/callback/single_call_callback.py +6 -3
  35. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/decorators.py +10 -4
  36. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/exceptions.py +1 -1
  37. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/immutable.py +17 -7
  38. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/is_frozen.py +1 -0
  39. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/odict.py +7 -3
  40. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/singleton.py +16 -10
  41. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/types_.py +6 -2
  42. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/weak_ref.py +38 -42
  43. oop_ext-2.3.1/src/oop_ext/interface/__init__.py +59 -0
  44. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/interface/_interface.py +51 -58
  45. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/interface/_tests/test_interface.py +98 -101
  46. oop_ext-2.3.1/src/oop_ext.egg-info/PKG-INFO +369 -0
  47. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext.egg-info/SOURCES.txt +6 -1
  48. oop_ext-2.3.1/tox.ini +14 -0
  49. oop-ext-2.1.0/.github/workflows/main.yml +0 -82
  50. oop-ext-2.1.0/.readthedocs.yml +0 -10
  51. oop-ext-2.1.0/PKG-INFO +0 -312
  52. oop-ext-2.1.0/src/oop_ext/foundation/callback/__init__.py +0 -28
  53. oop-ext-2.1.0/src/oop_ext/foundation/callback/_typed_callback.py +0 -207
  54. oop-ext-2.1.0/src/oop_ext/interface/__init__.py +0 -62
  55. oop-ext-2.1.0/src/oop_ext.egg-info/PKG-INFO +0 -312
  56. oop-ext-2.1.0/tox.ini +0 -29
  57. {oop-ext-2.1.0 → oop_ext-2.3.1}/.codecov.yml +0 -0
  58. {oop-ext-2.1.0 → oop_ext-2.3.1}/.editorconfig +0 -0
  59. {oop-ext-2.1.0 → oop_ext-2.3.1}/.gitattributes +0 -0
  60. {oop-ext-2.1.0 → oop_ext-2.3.1}/.isort.cfg +0 -0
  61. {oop-ext-2.1.0 → oop_ext-2.3.1}/.project +0 -0
  62. {oop-ext-2.1.0 → oop_ext-2.3.1}/.pydevproject +0 -0
  63. {oop-ext-2.1.0 → oop_ext-2.3.1}/CONTRIBUTING.rst +0 -0
  64. {oop-ext-2.1.0 → oop_ext-2.3.1}/LICENSE +0 -0
  65. {oop-ext-2.1.0 → oop_ext-2.3.1}/docs/api.rst +0 -0
  66. {oop-ext-2.1.0 → oop_ext-2.3.1}/docs/changelog.rst +0 -0
  67. {oop-ext-2.1.0 → oop_ext-2.3.1}/docs/contributing.rst +0 -0
  68. {oop-ext-2.1.0 → oop_ext-2.3.1}/docs/img/logo.png +0 -0
  69. {oop-ext-2.1.0 → oop_ext-2.3.1}/docs/index.rst +0 -0
  70. {oop-ext-2.1.0 → oop_ext-2.3.1}/docs/installation.rst +0 -0
  71. {oop-ext-2.1.0 → oop_ext-2.3.1}/docs/interfaces.rst +0 -0
  72. {oop-ext-2.1.0 → oop_ext-2.3.1}/docs/readme.rst +0 -0
  73. {oop-ext-2.1.0 → oop_ext-2.3.1}/environment.devenv.yml +0 -0
  74. {oop-ext-2.1.0 → oop_ext-2.3.1}/mypy.ini +0 -0
  75. {oop-ext-2.1.0 → oop_ext-2.3.1}/setup.cfg +0 -0
  76. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/__init__.py +0 -0
  77. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/__init__.py +0 -0
  78. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/_tests/__init__.py +0 -0
  79. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/_tests/test_odict.py +0 -0
  80. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/_tests/test_types.py +0 -0
  81. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/callback/_tests/__init__.py +0 -0
  82. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/callback/_tests/test_single_call_callback.py +0 -0
  83. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/foundation/compat.py +0 -0
  84. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/interface/_adaptable_interface.py +1 -1
  85. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/interface/_tests/__init__.py +0 -0
  86. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext/py.typed +0 -0
  87. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext.egg-info/dependency_links.txt +0 -0
  88. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext.egg-info/not-zip-safe +0 -0
  89. {oop-ext-2.1.0 → oop_ext-2.3.1}/src/oop_ext.egg-info/requires.txt +0 -0
  90. {oop-ext-2.1.0 → oop_ext-2.3.1}/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,57 @@
1
+ name: deploy
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ version:
7
+ description: 'Release version'
8
+ required: true
9
+ default: '1.2.3'
10
+
11
+ jobs:
12
+
13
+ package:
14
+ runs-on: ubuntu-latest
15
+ # Required by attest-build-provenance-github.
16
+ permissions:
17
+ id-token: write
18
+ attestations: write
19
+ env:
20
+ SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.version }}
21
+
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+
25
+ - name: Build and Check Package
26
+ uses: hynek/build-and-inspect-python-package@v2.13.0
27
+ with:
28
+ attest-build-provenance-github: 'true'
29
+
30
+
31
+ deploy:
32
+ needs: package
33
+ runs-on: ubuntu-latest
34
+ environment: deploy
35
+ permissions:
36
+ id-token: write # For PyPI trusted publishers.
37
+ contents: write # For tag and release notes.
38
+
39
+ steps:
40
+ - uses: actions/checkout@v4
41
+
42
+ - name: Download Package
43
+ uses: actions/download-artifact@v4
44
+ with:
45
+ name: Packages
46
+ path: dist
47
+
48
+ - name: Publish package to PyPI
49
+ uses: pypa/gh-action-pypi-publish@v1.12.4
50
+ with:
51
+ attestations: true
52
+
53
+ - name: GitHub Release
54
+ uses: softprops/action-gh-release@v2
55
+ with:
56
+ files: dist/*
57
+ tag_name: v${{ github.event.inputs.version }}
@@ -0,0 +1,79 @@
1
+ name: test
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+
8
+ pull_request:
9
+
10
+
11
+ concurrency:
12
+ group: ${{ github.workflow }}-${{ github.ref }}
13
+ cancel-in-progress: true
14
+
15
+ jobs:
16
+
17
+ package:
18
+ runs-on: ubuntu-latest
19
+ permissions:
20
+ id-token: write
21
+ attestations: write
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+ - name: Build and Check Package
25
+ uses: hynek/build-and-inspect-python-package@v2.13.0
26
+ with:
27
+ # Disabling because this is failing currently, see #466.
28
+ attest-build-provenance-github: 'false'
29
+
30
+ test:
31
+
32
+ needs: [package]
33
+
34
+ runs-on: ${{ matrix.os }}
35
+
36
+ strategy:
37
+ fail-fast: false
38
+ matrix:
39
+ python: ["3.10", "3.11", "3.12", "3.13"]
40
+ os: [ubuntu-latest, windows-latest]
41
+
42
+ steps:
43
+ - uses: actions/checkout@v4
44
+
45
+ - name: Download Package
46
+ uses: actions/download-artifact@v4
47
+ with:
48
+ name: Packages
49
+ path: dist
50
+
51
+ - name: Set up Python
52
+ uses: actions/setup-python@v5
53
+ with:
54
+ python-version: ${{ matrix.python }}
55
+
56
+ - name: Install tox
57
+ run: |
58
+ python -m pip install --upgrade pip
59
+ pip install tox
60
+
61
+ - name: Test
62
+ shell: bash
63
+ run: |
64
+ tox run -e py --installpkg `find dist/*.tar.gz`
65
+
66
+ sonarcloud:
67
+
68
+ runs-on: ubuntu-latest
69
+
70
+ steps:
71
+ - uses: actions/checkout@v4.2.2
72
+ with:
73
+ # Disabling shallow clone is recommended for improving relevancy of reporting
74
+ fetch-depth: 0
75
+ - name: SonarCloud Scan
76
+ uses: sonarsource/sonarcloud-github-action@master
77
+ env:
78
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79
+ 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: 25.1.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.1
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: 6.0.1
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.17.0
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,3 +1,30 @@
1
+ 2.3.1
2
+ -----
3
+
4
+ **Release**: 2025-08-01
5
+
6
+ * Fix type annotations:
7
+ * ``oop_ext.foundation.weak_ref.IsWeakProxy``.
8
+ * ``oop_ext.foundation.weak_ref.IsWeakRef``.
9
+ * ``oop_ext.foundation.weak_ref.GetWeakProxy``.
10
+
11
+
12
+ 2.3.0
13
+ -----
14
+
15
+ Not released due to a problem during deploy.
16
+
17
+ 2.2.0
18
+ -----
19
+
20
+ **Release**: 2024-10-24
21
+
22
+ * ``PriorityCallback`` now has type checking support, similar to ``Callback``, with type checked variants: ``PriorityCallback0``, ``PriorityCallback1``, etc (`#128`_).
23
+ * ``UnregisterContext`` is now public, meant to be used in type annotations.
24
+ * Python 3.10+ is now required.
25
+
26
+ .. _#128: https://github.com/ESSS/oop-ext/pull/128
27
+
1
28
  2.1.0 (2021-03-19)
2
29
  ------------------
3
30
 
@@ -71,8 +98,7 @@
71
98
  from oop_ext.foundation.callback import Callback2
72
99
 
73
100
 
74
- def changed(x: int, v: float) -> None:
75
- ...
101
+ def changed(x: int, v: float) -> None: ...
76
102
 
77
103
 
78
104
  on_changed = Callback2[int, float]()
oop_ext-2.3.1/PKG-INFO ADDED
@@ -0,0 +1,369 @@
1
+ Metadata-Version: 2.4
2
+ Name: oop-ext
3
+ Version: 2.3.1
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
+ Description-Content-Type: text/x-rst
19
+ License-File: LICENSE
20
+ Requires-Dist: attrs
21
+ Provides-Extra: docs
22
+ Requires-Dist: sphinx>=1.4; extra == "docs"
23
+ Requires-Dist: sphinx_rtd_theme; extra == "docs"
24
+ Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
25
+ Provides-Extra: testing
26
+ Requires-Dist: codecov; extra == "testing"
27
+ Requires-Dist: pytest; extra == "testing"
28
+ Requires-Dist: pytest-cov; extra == "testing"
29
+ Requires-Dist: pytest-mock; extra == "testing"
30
+ Requires-Dist: pre-commit; extra == "testing"
31
+ Requires-Dist: tox; extra == "testing"
32
+ Requires-Dist: mypy; extra == "testing"
33
+ Dynamic: author
34
+ Dynamic: author-email
35
+ Dynamic: classifier
36
+ Dynamic: description
37
+ Dynamic: description-content-type
38
+ Dynamic: home-page
39
+ Dynamic: keywords
40
+ Dynamic: license
41
+ Dynamic: license-file
42
+ Dynamic: provides-extra
43
+ Dynamic: requires-dist
44
+ Dynamic: requires-python
45
+ Dynamic: summary
46
+
47
+ ======================================================================
48
+ OOP Extensions
49
+ ======================================================================
50
+
51
+ .. image:: https://img.shields.io/pypi/v/oop-ext.svg
52
+ :target: https://pypi.python.org/pypi/oop-ext
53
+
54
+ .. image:: https://img.shields.io/pypi/pyversions/oop-ext.svg
55
+ :target: https://pypi.org/project/oop-ext
56
+
57
+ .. image:: https://github.com/ESSS/oop-ext/workflows/build/badge.svg
58
+ :target: https://github.com/ESSS/oop-ext/actions
59
+
60
+ .. image:: https://codecov.io/gh/ESSS/oop-ext/branch/master/graph/badge.svg
61
+ :target: https://codecov.io/gh/ESSS/oop-ext
62
+
63
+ .. image:: https://img.shields.io/readthedocs/oop-extensions.svg
64
+ :target: https://oop-extensions.readthedocs.io/en/latest/
65
+
66
+ .. image:: https://results.pre-commit.ci/badge/github/ESSS/oop-ext/master.svg
67
+ :target: https://results.pre-commit.ci/latest/github/ESSS/oop-ext/master
68
+
69
+ .. image:: https://sonarcloud.io/api/project_badges/measure?project=ESSS_oop-ext&metric=alert_status
70
+ :target: https://sonarcloud.io/project/overview?id=ESSS_oop-ext
71
+
72
+
73
+ What is OOP Extensions ?
74
+ ================================================================================
75
+
76
+ OOP Extensions is a set of utilities for object oriented programming which is missing on Python core libraries.
77
+
78
+ Usage
79
+ ================================================================================
80
+ ``oop_ext`` brings a set of object oriented utilities, it supports the concept of interfaces,
81
+ abstract/overridable methods and more. ``oop_ext`` carefully checks that implementations
82
+ have the same method signatures as the interface it implements and raises exceptions otherwise.
83
+
84
+ Here's a simple example showing some nice features:
85
+
86
+ .. code-block:: python
87
+
88
+ from oop_ext.interface import Interface, ImplementsInterface
89
+
90
+
91
+ class IDisposable(Interface):
92
+ def dispose(self):
93
+ """
94
+ Clears this object
95
+ """
96
+
97
+ def is_disposed(self) -> bool:
98
+ """
99
+ Returns True if the object has been cleared
100
+ """
101
+
102
+
103
+ @ImplementsInterface(IDisposable)
104
+ class MyObject(Disposable):
105
+ def __init__(self):
106
+ super().__init__()
107
+ self._data = [0] * 100
108
+ self._is_disposed = False
109
+
110
+ def is_disposed(self) -> bool:
111
+ return self._is_disposed
112
+
113
+ def dispose(self):
114
+ self._is_disposed = True
115
+ self._data = []
116
+
117
+
118
+ If any of the two methods in ``MyObject`` are not implemented or have differ signatures than
119
+ the ones declared in ``IDisposable``, the ``ImplementsInterface`` decorator will raise an
120
+ error during import.
121
+
122
+ Arbitrary objects can be verified if they implement a certain interface by using ``IsImplementation``:
123
+
124
+ .. code-block:: python
125
+
126
+ from oop_ext.interface import IsImplementation
127
+
128
+ my_object = MyObject()
129
+ if IsImplementation(my_object, IDisposable):
130
+ # my_object is guaranteed to implement IDisposable completely
131
+ my_object.dispose()
132
+
133
+ Alternatively you can assert that an object implements the desired interface with ``AssertImplements``:
134
+
135
+ .. code-block:: python
136
+
137
+ from oop_ext.interface import AssertImplements
138
+
139
+ my_object = MyObject()
140
+ AssertImplements(my_object, IDisposable)
141
+ my_object.dispose()
142
+
143
+
144
+ Type Checking
145
+ -------------
146
+
147
+ As of ``1.1.0``, ``oop-ext`` includes inline type annotations and exposes them to user programs.
148
+
149
+ If you are running a type checker such as mypy on your tests, you may start noticing type errors indicating incorrect usage.
150
+ If you run into an error that you believe to be incorrect, please let us know in an issue.
151
+
152
+ The types were developed against ``mypy`` version 0.800.
153
+
154
+ See `the docs <https://oop-extensions.readthedocs.io/en/latest/interfaces.html#static-type-checking>`__
155
+ for more information.
156
+
157
+ Contributing
158
+ ------------
159
+
160
+ For guidance on setting up a development environment and how to make a
161
+ contribution to oop_ext, see the `contributing guidelines`_.
162
+
163
+ .. _contributing guidelines: https://github.com/ESSS/oop-ext/blob/master/CONTRIBUTING.rst
164
+
165
+
166
+ Release
167
+ -------
168
+ A reminder for the maintainers on how to make a new release.
169
+
170
+ Note that the VERSION should follow the semantic versioning as ``X.Y.Z`` (e.g. ``v1.0.5``).
171
+
172
+ 1. Create a ``release-VERSION`` branch from ``upstream/master``.
173
+ 2. Update ``CHANGELOG.rst``.
174
+ 3. Push the branch to ``upstream``.
175
+ 4. Once all tests pass, start the ``deploy`` workflow manually or via::
176
+
177
+ gh workflow run deploy.yml --repo ESSS/oop-ext --ref release-VERSION -f version=VERSION
178
+
179
+ 5. Merge the PR.
180
+
181
+
182
+ 2.3.1
183
+ -----
184
+
185
+ **Release**: 2025-08-01
186
+
187
+ * Fix type annotations:
188
+ * ``oop_ext.foundation.weak_ref.IsWeakProxy``.
189
+ * ``oop_ext.foundation.weak_ref.IsWeakRef``.
190
+ * ``oop_ext.foundation.weak_ref.GetWeakProxy``.
191
+
192
+
193
+ 2.3.0
194
+ -----
195
+
196
+ Not released due to a problem during deploy.
197
+
198
+ 2.2.0
199
+ -----
200
+
201
+ **Release**: 2024-10-24
202
+
203
+ * ``PriorityCallback`` now has type checking support, similar to ``Callback``, with type checked variants: ``PriorityCallback0``, ``PriorityCallback1``, etc (`#128`_).
204
+ * ``UnregisterContext`` is now public, meant to be used in type annotations.
205
+ * Python 3.10+ is now required.
206
+
207
+ .. _#128: https://github.com/ESSS/oop-ext/pull/128
208
+
209
+ 2.1.0 (2021-03-19)
210
+ ------------------
211
+
212
+ * #48: New type-checker friendly ``proxy = GetProxy(I, obj)`` function as an alternative to ``proxy = I(obj)``. The
213
+ latter is not accepted by type checkers in general because interfaces are protocols, which can't be instantiated.
214
+
215
+ Also fixed a type-checking error with ``AsssertImplements``::
216
+
217
+ Only concrete class can be given where "Type[Interface]" is expected
218
+
219
+ This happens due to `python/mypy#5374 <https://github.com/python/mypy/issues/5374>`__.
220
+
221
+
222
+ 2.0.0 (2021-03-10)
223
+ ------------------
224
+
225
+ * #47: Interfaces no longer check type annotations at all.
226
+
227
+ It was supported initially, but in practice
228
+ this feature has shown up to be an impediment to adopting type annotations incrementally, as it
229
+ discourages adding type annotations to improve existing interfaces, or annotating
230
+ existing implementations without having to update the interface (and all other implementations
231
+ by consequence).
232
+
233
+ It was decided to let the static type checker correctly deal with matching type annotations, as
234
+ it can do so more accurately than ``oop-ext`` did before.
235
+
236
+ 1.2.0 (2021-03-09)
237
+ ------------------
238
+
239
+ * #43: Fix support for type annotated ``Attribute`` and ``ReadOnlyAttribute``:
240
+
241
+ .. code-block:: python
242
+
243
+ class IFoo(Interface):
244
+ value: int = Attribute(int)
245
+
246
+ 1.1.2 (2021-02-23)
247
+ ------------------
248
+
249
+ * #41: Fix regression introduced in ``1.1.0`` where installing a callback using
250
+ ``callback.After`` or ``callback.Before`` would make a method no longer compliant with
251
+ the signature required by its interface.
252
+
253
+ 1.1.1 (2021-02-23)
254
+ ------------------
255
+
256
+ * #38: Reintroduce ``extra_args`` argument to ``Callback._GetKey``, so subclasses can make use
257
+ of it.
258
+
259
+ * #36: Fix regression introduced in ``1.1.0`` where ``Abstract`` and ``Implements`` decorators
260
+ could no longer be used in interfaces implementations.
261
+
262
+ 1.1.0 (2021-02-19)
263
+ ------------------
264
+
265
+ * #25: ``oop-ext`` now includes inline type annotations and exposes them to user programs.
266
+
267
+ If you are running a type checker such as mypy on your tests, you may start noticing type errors indicating incorrect usage.
268
+ If you run into an error that you believe to be incorrect, please let us know in an issue.
269
+
270
+ The types were developed against ``mypy`` version 0.800.
271
+
272
+ * #26: New type-checked ``Callback`` variants, ``Callback0``, ``Callback1``, ``Callback2``, etc, providing
273
+ type checking for all operations(calling, ``Register``, etc) at nearly zero runtime cost.
274
+
275
+ Example:
276
+
277
+ .. code-block:: python
278
+
279
+ from oop_ext.foundation.callback import Callback2
280
+
281
+
282
+ def changed(x: int, v: float) -> None: ...
283
+
284
+
285
+ on_changed = Callback2[int, float]()
286
+ on_changed(10, 5.25)
287
+
288
+
289
+ * Fixed ``Callbacks.Before`` and ``Callbacks.After`` signatures: previously their signature conveyed
290
+ that they supported multiple callbacks, but it was a mistake which would break callers because
291
+ every parameter after the 2nd would be considered the ``sender_as_parameter`` parameter, which
292
+ was forwarded to ``After`` and ``Before`` functions of the ``_shortcuts.py``
293
+ module.
294
+
295
+ 1.0.0 (2020-10-01)
296
+ ------------------
297
+
298
+ * ``Callbacks`` can be used as context manager, which provides a ``Register(callback, function)``,
299
+ which automatically unregisters all functions when the context manager ends.
300
+
301
+ * ``Callback.Register(function)`` now returns an object with a ``Unregister()`` method, which
302
+ can be used to undo the register call.
303
+
304
+ 0.6.0 (2020-01-31)
305
+ ==================
306
+
307
+ * Change back the default value of ``requires_declaration`` to ``True`` and fix an error (#22) where the cache wasn't properly cleared.
308
+
309
+ 0.5.1 (2019-12-20)
310
+ ------------------
311
+
312
+ * Fixes an issue (#20) where mocked `classmethods` weren't considered a valid method during internal checks.
313
+
314
+ 0.5.0 (2019-12-12)
315
+ ------------------
316
+
317
+ * Add optional argument ``requires_declaration`` so users can decide whether or not ``@ImplementsInterface`` declarations are necessary.
318
+
319
+ 0.4.0 (2019-12-03)
320
+ ------------------
321
+
322
+ * 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.
323
+
324
+ 0.3.2 (2019-08-22)
325
+ ------------------
326
+
327
+ * Interface and implementation methods can no longer contain mutable defaults, as this is considered
328
+ a bad practice in general.
329
+
330
+ * ``Null`` instances are now hashable.
331
+
332
+
333
+ 0.3.1 (2019-08-16)
334
+ ------------------
335
+
336
+ * Fix mismatching signatures when creating "interface stubs" for instances:
337
+
338
+ .. code-block:: python
339
+
340
+ foo = IFoo(Foo())
341
+
342
+
343
+ 0.3.0 (2019-08-08)
344
+ ------------------
345
+
346
+ * Interfaces now support keyword-only arguments.
347
+
348
+ 0.2.4 (2019-03-22)
349
+ ------------------
350
+
351
+ * Remove ``FunctionNotRegisteredError`` exception, which has not been in use for a few years.
352
+
353
+
354
+ 0.2.3 (2019-03-22)
355
+ ------------------
356
+
357
+ * Fix issues of ignored exception on nested callback.
358
+
359
+
360
+ 0.2.1 (2019-03-14)
361
+ ------------------
362
+
363
+ * Fix issues and remove obsolete code.
364
+
365
+
366
+ 0.1.8 (2019-03-12)
367
+ ------------------
368
+
369
+ * 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,11 +121,13 @@ 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``.
125
- 3. Push a branch with the changes.
126
- 4. Once all builds pass, push a ``VERSION`` tag to ``upstream``.
128
+ 3. Push the branch to ``upstream``.
129
+ 4. Once all tests pass, start the ``deploy`` workflow manually or via::
130
+
131
+ gh workflow run deploy.yml --repo ESSS/oop-ext --ref release-VERSION -f version=VERSION
132
+
127
133
  5. Merge the PR.
@@ -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.