oop-ext 2.3.3__tar.gz → 2.4.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 (83) hide show
  1. {oop_ext-2.3.3 → oop_ext-2.4.0}/.github/workflows/deploy.yml +6 -6
  2. {oop_ext-2.3.3 → oop_ext-2.4.0}/.github/workflows/test.yml +6 -21
  3. {oop_ext-2.3.3 → oop_ext-2.4.0}/.pre-commit-config.yaml +7 -7
  4. {oop_ext-2.3.3 → oop_ext-2.4.0}/CHANGELOG.rst +10 -0
  5. {oop_ext-2.3.3 → oop_ext-2.4.0}/PKG-INFO +14 -3
  6. {oop_ext-2.3.3 → oop_ext-2.4.0}/setup.py +4 -2
  7. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/_tests/test_cached_method.py +9 -9
  8. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/_tests/test_immutable.py +16 -0
  9. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/_tests/test_types.py +2 -2
  10. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/_tests/test_weak_ref.py +9 -10
  11. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/cached_method.py +1 -1
  12. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/callback/_callback.py +13 -15
  13. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/callback/_priority_callback.py +2 -2
  14. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/callback/_shortcuts.py +4 -4
  15. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/callback/_tests/test_callback.py +2 -2
  16. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/callback/_tests/test_typed_callback.py +18 -36
  17. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/callback/_typed_callback.py +13 -16
  18. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/compat.py +1 -0
  19. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/decorators.py +1 -0
  20. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/immutable.py +11 -9
  21. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/odict.py +1 -1
  22. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/types_.py +1 -0
  23. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/weak_ref.py +7 -7
  24. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/interface/_interface.py +26 -18
  25. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/interface/_tests/test_interface.py +71 -47
  26. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext.egg-info/PKG-INFO +14 -3
  27. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext.egg-info/SOURCES.txt +1 -0
  28. oop_ext-2.4.0/src/oop_ext.egg-info/scm_file_list.json +78 -0
  29. {oop_ext-2.3.3 → oop_ext-2.4.0}/.codecov.yml +0 -0
  30. {oop_ext-2.3.3 → oop_ext-2.4.0}/.editorconfig +0 -0
  31. {oop_ext-2.3.3 → oop_ext-2.4.0}/.gitattributes +0 -0
  32. {oop_ext-2.3.3 → oop_ext-2.4.0}/.github/dependabot.yml +0 -0
  33. {oop_ext-2.3.3 → oop_ext-2.4.0}/.gitignore +0 -0
  34. {oop_ext-2.3.3 → oop_ext-2.4.0}/.isort.cfg +0 -0
  35. {oop_ext-2.3.3 → oop_ext-2.4.0}/.project +0 -0
  36. {oop_ext-2.3.3 → oop_ext-2.4.0}/.pydevproject +0 -0
  37. {oop_ext-2.3.3 → oop_ext-2.4.0}/.readthedocs.yml +0 -0
  38. {oop_ext-2.3.3 → oop_ext-2.4.0}/CONTRIBUTING.rst +0 -0
  39. {oop_ext-2.3.3 → oop_ext-2.4.0}/LICENSE +0 -0
  40. {oop_ext-2.3.3 → oop_ext-2.4.0}/README.rst +0 -0
  41. {oop_ext-2.3.3 → oop_ext-2.4.0}/docs/api.rst +0 -0
  42. {oop_ext-2.3.3 → oop_ext-2.4.0}/docs/callbacks.rst +0 -0
  43. {oop_ext-2.3.3 → oop_ext-2.4.0}/docs/changelog.rst +0 -0
  44. {oop_ext-2.3.3 → oop_ext-2.4.0}/docs/conf.py +0 -0
  45. {oop_ext-2.3.3 → oop_ext-2.4.0}/docs/contributing.rst +0 -0
  46. {oop_ext-2.3.3 → oop_ext-2.4.0}/docs/img/logo.png +0 -0
  47. {oop_ext-2.3.3 → oop_ext-2.4.0}/docs/index.rst +0 -0
  48. {oop_ext-2.3.3 → oop_ext-2.4.0}/docs/installation.rst +0 -0
  49. {oop_ext-2.3.3 → oop_ext-2.4.0}/docs/interfaces.rst +0 -0
  50. {oop_ext-2.3.3 → oop_ext-2.4.0}/docs/readme.rst +0 -0
  51. {oop_ext-2.3.3 → oop_ext-2.4.0}/docs/requirements.txt +0 -0
  52. {oop_ext-2.3.3 → oop_ext-2.4.0}/environment.devenv.yml +0 -0
  53. {oop_ext-2.3.3 → oop_ext-2.4.0}/mypy.ini +0 -0
  54. {oop_ext-2.3.3 → oop_ext-2.4.0}/pyproject.toml +0 -0
  55. {oop_ext-2.3.3 → oop_ext-2.4.0}/setup.cfg +0 -0
  56. {oop_ext-2.3.3 → oop_ext-2.4.0}/sonar-project.properties +0 -0
  57. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/__init__.py +0 -0
  58. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/_type_checker_fixture.py +0 -0
  59. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/conftest.py +0 -0
  60. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/__init__.py +0 -0
  61. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/_tests/__init__.py +0 -0
  62. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/_tests/test_decorators.py +0 -0
  63. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/_tests/test_is_frozen.py +0 -0
  64. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/_tests/test_odict.py +0 -0
  65. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/_tests/test_singleton.py +0 -0
  66. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/callback/__init__.py +0 -0
  67. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/callback/_callbacks.py +0 -0
  68. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/callback/_tests/__init__.py +0 -0
  69. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/callback/_tests/test_priority_callback.py +0 -0
  70. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/callback/_tests/test_single_call_callback.py +0 -0
  71. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/callback/single_call_callback.py +0 -0
  72. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/exceptions.py +0 -0
  73. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/is_frozen.py +0 -0
  74. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/foundation/singleton.py +0 -0
  75. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/interface/__init__.py +0 -0
  76. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/interface/_adaptable_interface.py +0 -0
  77. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/interface/_tests/__init__.py +0 -0
  78. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext/py.typed +0 -0
  79. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext.egg-info/dependency_links.txt +0 -0
  80. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext.egg-info/not-zip-safe +0 -0
  81. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext.egg-info/requires.txt +0 -0
  82. {oop_ext-2.3.3 → oop_ext-2.4.0}/src/oop_ext.egg-info/top_level.txt +0 -0
  83. {oop_ext-2.3.3 → oop_ext-2.4.0}/tox.ini +0 -0
@@ -20,10 +20,10 @@ jobs:
20
20
  SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.version }}
21
21
 
22
22
  steps:
23
- - uses: actions/checkout@v4
23
+ - uses: actions/checkout@v7
24
24
 
25
25
  - name: Build and Check Package
26
- uses: hynek/build-and-inspect-python-package@v2.13.0
26
+ uses: hynek/build-and-inspect-python-package@v2.18.0
27
27
  with:
28
28
  attest-build-provenance-github: 'true'
29
29
 
@@ -37,21 +37,21 @@ jobs:
37
37
  contents: write # For tag and release notes.
38
38
 
39
39
  steps:
40
- - uses: actions/checkout@v4
40
+ - uses: actions/checkout@v7
41
41
 
42
42
  - name: Download Package
43
- uses: actions/download-artifact@v4
43
+ uses: actions/download-artifact@v8
44
44
  with:
45
45
  name: Packages
46
46
  path: dist
47
47
 
48
48
  - name: Publish package to PyPI
49
- uses: pypa/gh-action-pypi-publish@v1.12.4
49
+ uses: pypa/gh-action-pypi-publish@v1.14.0
50
50
  with:
51
51
  attestations: true
52
52
 
53
53
  - name: GitHub Release
54
- uses: softprops/action-gh-release@v2
54
+ uses: softprops/action-gh-release@v3
55
55
  with:
56
56
  files: dist/*
57
57
  tag_name: v${{ github.event.inputs.version }}
@@ -20,9 +20,9 @@ jobs:
20
20
  id-token: write
21
21
  attestations: write
22
22
  steps:
23
- - uses: actions/checkout@v4
23
+ - uses: actions/checkout@v7
24
24
  - name: Build and Check Package
25
- uses: hynek/build-and-inspect-python-package@v2.13.0
25
+ uses: hynek/build-and-inspect-python-package@v2.18.0
26
26
  with:
27
27
  # Disabling because this is failing currently, see #466.
28
28
  attest-build-provenance-github: 'false'
@@ -36,20 +36,20 @@ jobs:
36
36
  strategy:
37
37
  fail-fast: false
38
38
  matrix:
39
- python: ["3.10", "3.11", "3.12", "3.13"]
39
+ python: ["3.11", "3.12", "3.13", "3.14", "3.15"]
40
40
  os: [ubuntu-latest, windows-latest]
41
41
 
42
42
  steps:
43
- - uses: actions/checkout@v4
43
+ - uses: actions/checkout@v7
44
44
 
45
45
  - name: Download Package
46
- uses: actions/download-artifact@v4
46
+ uses: actions/download-artifact@v8
47
47
  with:
48
48
  name: Packages
49
49
  path: dist
50
50
 
51
51
  - name: Set up Python
52
- uses: actions/setup-python@v5
52
+ uses: actions/setup-python@v6
53
53
  with:
54
54
  python-version: ${{ matrix.python }}
55
55
 
@@ -62,18 +62,3 @@ jobs:
62
62
  shell: bash
63
63
  run: |
64
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 }}
@@ -1,23 +1,23 @@
1
1
  repos:
2
- - repo: https://github.com/psf/black
3
- rev: 25.1.0
2
+ - repo: https://github.com/psf/black-pre-commit-mirror
3
+ rev: 26.10.1
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: 1.19.1
9
+ rev: 1.21.0
10
10
  hooks:
11
11
  - id: blacken-docs
12
12
  additional_dependencies: [black==24.10.0]
13
13
  - repo: https://github.com/pre-commit/pre-commit-hooks
14
- rev: v5.0.0
14
+ rev: v6.0.0
15
15
  hooks:
16
16
  - id: trailing-whitespace
17
17
  - id: end-of-file-fixer
18
18
  - id: debug-statements
19
19
  - repo: https://github.com/pycqa/isort
20
- rev: 6.0.1
20
+ rev: 10.0.0b3
21
21
  hooks:
22
22
  - id: isort
23
23
  name: isort
@@ -26,12 +26,12 @@ repos:
26
26
  hooks:
27
27
  - id: rst
28
28
  name: rst
29
- entry: rst-lint --encoding utf-8
29
+ entry: rst-lint
30
30
  files: ^(CHANGELOG.rst|README.rst)$
31
31
  language: python
32
32
  additional_dependencies: [pygments, restructuredtext_lint]
33
33
  - repo: https://github.com/pre-commit/mirrors-mypy
34
- rev: v1.17.1
34
+ rev: v2.4.1
35
35
  hooks:
36
36
  - id: mypy
37
37
  files: ^(src/)
@@ -1,3 +1,13 @@
1
+ 2.4.0
2
+ -----
3
+
4
+ **Release**: 2026-11-30
5
+
6
+ * Added support for Python 3.14 and 3.15.
7
+ * Dropped support for Python 3.10.
8
+ * Fixed interface checks keeping classes created at runtime, and everything they reference, alive forever (`#202 <https://github.com/ESSS/oop-ext/issues/202>`__).
9
+ * Fixed import error when ``typing_extensions`` is not installed.
10
+
1
11
  2.3.3
2
12
  -----
3
13
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oop-ext
3
- Version: 2.3.3
3
+ Version: 2.4.0
4
4
  Summary: OOP Extensions is a set of utilities for object oriented programming not found on Python's standard library.
5
5
  Home-page: http://github.com/ESSS/oop-ext
6
6
  Author: ESSS
@@ -10,11 +10,12 @@ Keywords: oop_ext
10
10
  Classifier: Development Status :: 5 - Production/Stable
11
11
  Classifier: Intended Audience :: Developers
12
12
  Classifier: License :: OSI Approved :: MIT License
13
- Classifier: Programming Language :: Python :: 3.10
14
13
  Classifier: Programming Language :: Python :: 3.11
15
14
  Classifier: Programming Language :: Python :: 3.12
16
15
  Classifier: Programming Language :: Python :: 3.13
17
- Requires-Python: >=3.10
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Programming Language :: Python :: 3.15
18
+ Requires-Python: >=3.11
18
19
  Description-Content-Type: text/x-rst
19
20
  License-File: LICENSE
20
21
  Requires-Dist: attrs
@@ -179,6 +180,16 @@ Note that the VERSION should follow the semantic versioning as ``X.Y.Z`` (e.g. `
179
180
  5. Merge the PR.
180
181
 
181
182
 
183
+ 2.4.0
184
+ -----
185
+
186
+ **Release**: 2026-11-30
187
+
188
+ * Added support for Python 3.14 and 3.15.
189
+ * Dropped support for Python 3.10.
190
+ * Fixed interface checks keeping classes created at runtime, and everything they reference, alive forever (`#202 <https://github.com/ESSS/oop-ext/issues/202>`__).
191
+ * Fixed import error when ``typing_extensions`` is not installed.
192
+
182
193
  2.3.3
183
194
  -----
184
195
 
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding: utf-8 -*-
3
3
  """The setup script."""
4
+
4
5
  import io
5
6
  from setuptools import find_packages
6
7
  from setuptools import setup
@@ -31,10 +32,11 @@ setup(
31
32
  "Development Status :: 5 - Production/Stable",
32
33
  "Intended Audience :: Developers",
33
34
  "License :: OSI Approved :: MIT License",
34
- "Programming Language :: Python :: 3.10",
35
35
  "Programming Language :: Python :: 3.11",
36
36
  "Programming Language :: Python :: 3.12",
37
37
  "Programming Language :: Python :: 3.13",
38
+ "Programming Language :: Python :: 3.14",
39
+ "Programming Language :: Python :: 3.15",
38
40
  ],
39
41
  description="OOP Extensions is a set of utilities for object oriented programming not found on Python's standard library.",
40
42
  extras_require=extras_require,
@@ -43,7 +45,7 @@ setup(
43
45
  long_description_content_type="text/x-rst",
44
46
  long_description=readme + "\n\n" + history,
45
47
  include_package_data=True,
46
- python_requires=">=3.10",
48
+ python_requires=">=3.11",
47
49
  keywords="oop_ext",
48
50
  name="oop-ext",
49
51
  packages=find_packages(where="src"),
@@ -107,27 +107,27 @@ def testCacheMethodAttributeBasedCachedMethod() -> None:
107
107
  return "%s %d" % (par, self.id)
108
108
 
109
109
  alpha = TestObject()
110
- alpha.Foo = AttributeBasedCachedMethod( # type:ignore[assignment]
110
+ alpha.Foo = AttributeBasedCachedMethod( # type: ignore[assignment]
111
111
  alpha.Foo, "id", cache_size=3
112
112
  )
113
- alpha.Foo("test1") # type:ignore[misc]
114
- alpha.Foo("test1") # type:ignore[misc]
113
+ alpha.Foo("test1") # type: ignore[misc]
114
+ alpha.Foo("test1") # type: ignore[misc]
115
115
 
116
116
  assert alpha.n_calls == 1
117
117
 
118
- alpha.Foo("test2") # type:ignore[misc]
118
+ alpha.Foo("test2") # type: ignore[misc]
119
119
  assert alpha.n_calls == 2
120
- assert len(alpha.Foo._results) == 2 # type:ignore[attr-defined]
120
+ assert len(alpha.Foo._results) == 2 # type: ignore[attr-defined]
121
121
 
122
122
  alpha.id = 3
123
- alpha.Foo("test2") # type:ignore[misc]
123
+ alpha.Foo("test2") # type: ignore[misc]
124
124
  assert alpha.n_calls == 3
125
125
 
126
- assert len(alpha.Foo._results) == 3 # type:ignore[attr-defined]
126
+ assert len(alpha.Foo._results) == 3 # type: ignore[attr-defined]
127
127
 
128
- alpha.Foo("test3") # type:ignore[misc]
128
+ alpha.Foo("test3") # type: ignore[misc]
129
129
  assert alpha.n_calls == 4
130
- assert len(alpha.Foo._results) == 3 # type:ignore[attr-defined]
130
+ assert len(alpha.Foo._results) == 3 # type: ignore[attr-defined]
131
131
 
132
132
 
133
133
  @pytest.fixture
@@ -5,6 +5,7 @@ from copy import deepcopy
5
5
  from oop_ext.foundation.immutable import AsImmutable
6
6
  from oop_ext.foundation.immutable import IdentityHashableRef
7
7
  from oop_ext.foundation.immutable import ImmutableDict
8
+ from oop_ext.foundation.immutable import RegisterAsImmutable
8
9
 
9
10
 
10
11
  def testImmutable() -> None:
@@ -106,3 +107,18 @@ def testIdentityHashableRef() -> None:
106
107
  assert IdentityHashableRef(a) not in dict_b
107
108
  assert IdentityHashableRef(b) in dict_b
108
109
  assert dict_b[IdentityHashableRef(b)] == 7
110
+
111
+
112
+ def testRegisterAsImmutableCopyReturnsSameInstance() -> None:
113
+ """Shallow copies of registered immutable types are the original instance."""
114
+
115
+ class Point:
116
+ pass
117
+
118
+ RegisterAsImmutable(Point)
119
+ p = Point()
120
+ assert copy(p) is p
121
+ assert AsImmutable(p) is p
122
+
123
+ ref = IdentityHashableRef(p)
124
+ assert copy(ref) is ref
@@ -26,10 +26,10 @@ def testNull() -> None:
26
26
  n.method1().attr1
27
27
 
28
28
  n.attr1 = "value"
29
- n.attr1.attr2 = "value" # type:ignore[attr-defined]
29
+ n.attr1.attr2 = "value" # type: ignore[attr-defined]
30
30
 
31
31
  del n.attr1
32
- del n.attr1.attr2.attr3 # type:ignore[attr-defined]
32
+ del n.attr1.attr2.attr3 # type: ignore[attr-defined]
33
33
 
34
34
  # Iteration
35
35
  for _ in n:
@@ -346,22 +346,21 @@ def testCustomAssertEqual() -> None:
346
346
  def testRefcount() -> None:
347
347
  _, c, _ = SetupTestAttributes()
348
348
 
349
- CustomAssertEqual(
350
- sys.getrefcount(c), 2
351
- ) # 2: one in self, and one as argument to getrefcount()
349
+ # Relative to a baseline because Python 3.14 no longer counts the argument reference.
350
+ base = sys.getrefcount(c)
352
351
  cf = c.f
353
- CustomAssertEqual(sys.getrefcount(c), 3) # 3: as above, plus cf
352
+ CustomAssertEqual(sys.getrefcount(c), base + 1)
354
353
  rf = WeakMethodRef(c.f)
355
354
  pf = WeakMethodProxy(c.f)
356
- CustomAssertEqual(sys.getrefcount(c), 3)
355
+ CustomAssertEqual(sys.getrefcount(c), base + 1)
357
356
  del cf
358
- CustomAssertEqual(sys.getrefcount(c), 2)
357
+ CustomAssertEqual(sys.getrefcount(c), base)
359
358
  rf2 = WeakMethodRef(c.f)
360
- CustomAssertEqual(sys.getrefcount(c), 2)
359
+ CustomAssertEqual(sys.getrefcount(c), base)
361
360
  del rf
362
361
  del rf2
363
362
  del pf
364
- CustomAssertEqual(sys.getrefcount(c), 2)
363
+ CustomAssertEqual(sys.getrefcount(c), base)
365
364
 
366
365
 
367
366
  def testDies() -> None:
@@ -510,13 +509,13 @@ def testWeakList() -> None:
510
509
  def m1() -> None:
511
510
  "Never called"
512
511
 
513
- weak_list.append(m1) # type:ignore[arg-type]
512
+ weak_list.append(m1) # type: ignore[arg-type]
514
513
  assert 1 == len(weak_list[:])
515
514
  del m1
516
515
  assert 0 == len(weak_list[:])
517
516
 
518
517
  s = _Stub()
519
- weak_list.append(s.Method) # type:ignore[arg-type]
518
+ weak_list.append(s.Method) # type: ignore[arg-type]
520
519
  assert 1 == len(weak_list[:])
521
520
  ref_s = weakref.ref(s)
522
521
  del s
@@ -148,7 +148,7 @@ class LastResultCachedMethod(AbstractCachedMethod, Generic[ResultType]):
148
148
  def _GetCacheResult(self, key: Hashable, result: ResultType) -> ResultType:
149
149
  # This could return None (_result is Optional), but not doing an assert
150
150
  # here to avoid breaking code.
151
- return self._result # type:ignore[return-value]
151
+ return self._result # type: ignore[return-value]
152
152
 
153
153
 
154
154
  class AttributeBasedCachedMethod(CachedMethod, Generic[ResultType]):
@@ -49,12 +49,12 @@ We can unregister functions using :meth:`Unregister <Callback.Unregister>`, chec
49
49
  is registered with :meth:`Contains <Callback.Contains>`, and unregister all connected functions
50
50
  with :meth:`UnregisterAll <Callback.UnregisterAll>`.
51
51
  """
52
+
52
53
  import types
53
54
  from typing import Any
54
55
  from typing import Optional
55
56
  from typing import Tuple
56
57
  from typing import Union
57
- from typing import cast
58
58
 
59
59
  import attr
60
60
  import functools
@@ -188,20 +188,19 @@ class Callback:
188
188
  is garbage collected, a new function may end up having the same key.
189
189
  """
190
190
  if func.__class__ == _CallbackWrapper:
191
- func = cast(_CallbackWrapper, func)
192
191
  func = func.OriginalMethod()
193
192
 
194
193
  try:
195
- if func.__self__ is not None: # type:ignore[union-attr]
194
+ if func.__self__ is not None: # type: ignore[union-attr]
196
195
  # bound method
197
196
  return (
198
- id(func.__self__), # type:ignore[union-attr]
199
- id(func.__func__), # type:ignore[union-attr]
200
- id(func.__self__.__class__), # type:ignore[union-attr]
197
+ id(func.__self__), # type: ignore[union-attr]
198
+ id(func.__func__), # type: ignore[union-attr]
199
+ id(func.__self__.__class__), # type: ignore[union-attr]
201
200
  )
202
201
  else:
203
202
  return (
204
- id(func.__func__), # type:ignore[union-attr]
203
+ id(func.__func__), # type: ignore[union-attr]
205
204
  id(GetClassForUnboundMethod(func)),
206
205
  )
207
206
 
@@ -223,7 +222,6 @@ class Callback:
223
222
  # at this point, but if it's a WeakMethodProxy, register the original method (we'll make a
224
223
  # weak reference later anyways).
225
224
  if func.__class__ == WeakMethodProxy:
226
- func = cast(WeakMethodProxy, func)
227
225
  func = func.GetWrappedFunction()
228
226
 
229
227
  if _IsCallableObject(func):
@@ -240,20 +238,20 @@ class Callback:
240
238
 
241
239
  try:
242
240
  if (
243
- func.__self__ is not None # type:ignore[union-attr]
244
- and func.__func__ is not None # type:ignore[union-attr]
241
+ func.__self__ is not None # type: ignore[union-attr]
242
+ and func.__func__ is not None # type: ignore[union-attr]
245
243
  ):
246
244
  # bound method
247
245
  return (
248
- weakref.ref(func.__self__), # type:ignore[union-attr]
249
- func.__func__, # type:ignore[union-attr]
250
- func.__self__.__class__, # type:ignore[union-attr]
246
+ weakref.ref(func.__self__), # type: ignore[union-attr]
247
+ func.__func__, # type: ignore[union-attr]
248
+ func.__self__.__class__, # type: ignore[union-attr]
251
249
  )
252
250
  else:
253
251
  # unbound method
254
252
  return (
255
253
  None,
256
- func.__func__, # type:ignore[union-attr]
254
+ func.__func__, # type: ignore[union-attr]
257
255
  GetClassForUnboundMethod(func),
258
256
  )
259
257
  except AttributeError:
@@ -424,7 +422,7 @@ class Callback:
424
422
  if func_func == real_func:
425
423
  return True
426
424
  try:
427
- f = real_func.__func__ # type:ignore[union-attr]
425
+ f = real_func.__func__ # type: ignore[union-attr]
428
426
  except AttributeError:
429
427
  return False
430
428
  else:
@@ -20,7 +20,7 @@ class PriorityCallback(Callback):
20
20
  INFO_POS_PRIORITY = 3
21
21
 
22
22
  @Override(Callback._GetInfo)
23
- def _GetInfo( # type:ignore[misc, override]
23
+ def _GetInfo( # type: ignore[misc, override]
24
24
  self, func: Callable, priority: int
25
25
  ) -> Any:
26
26
  """
@@ -33,7 +33,7 @@ class PriorityCallback(Callback):
33
33
  return info + (priority,)
34
34
 
35
35
  @Override(Callback.Register)
36
- def Register( # type:ignore[misc, override]
36
+ def Register( # type: ignore[misc, override]
37
37
  self,
38
38
  func: Callable,
39
39
  extra_args: tuple[object, ...] = Callback._EXTRA_ARGS_CONSTANT,
@@ -174,7 +174,7 @@ def _GetWrapped(method: Method | _MethodWrapper | Callable) -> _MethodWrapper |
174
174
  if isinstance(method, _MethodWrapper):
175
175
  return method
176
176
  try:
177
- return method._wrapped_instance # type:ignore[attr-defined, union-attr]
177
+ return method._wrapped_instance # type: ignore[attr-defined, union-attr]
178
178
  except AttributeError:
179
179
  return None
180
180
 
@@ -194,7 +194,7 @@ def WrapForCallback(method: Method | _MethodWrapper | Callable) -> _MethodWrappe
194
194
  # Note that the other way around does not work at all (i.e.: if a callback is first added
195
195
  # to the instance, there's no way we'll find about that when adding it to the class
196
196
  # anyways).
197
- if method.__self__ is None: # type:ignore[union-attr]
197
+ if method.__self__ is None: # type: ignore[union-attr]
198
198
  if wrapped._method._obj is None:
199
199
  return wrapped
200
200
 
@@ -208,10 +208,10 @@ def WrapForCallback(method: Method | _MethodWrapper | Callable) -> _MethodWrappe
208
208
  return wrapper(*args, **kwargs)
209
209
 
210
210
  call.__name__ = method.__name__
211
- call._wrapped_instance = wrapper # type:ignore[attr-defined]
211
+ call._wrapped_instance = wrapper # type: ignore[attr-defined]
212
212
 
213
213
  setattr(GetClassForUnboundMethod(method), method.__name__, call)
214
214
  else:
215
215
  # override the instance method
216
- setattr(method.__self__, method.__name__, wrapper) # type:ignore[union-attr]
216
+ setattr(method.__self__, method.__name__, wrapper) # type: ignore[union-attr]
217
217
  return wrapper
@@ -53,8 +53,8 @@ def restore_test_classes() -> Generator[None, None, None]:
53
53
  original_c_foo = C.foo
54
54
 
55
55
  yield
56
- Stub.call = original_stub_call # type:ignore[assignment]
57
- C.foo = original_c_foo # type:ignore[assignment]
56
+ Stub.call = original_stub_call # type: ignore[assignment]
57
+ C.foo = original_c_foo # type: ignore[assignment]
58
58
 
59
59
 
60
60
  class Test:
@@ -7,8 +7,7 @@ from oop_ext._type_checker_fixture import TypeCheckerFixture
7
7
 
8
8
 
9
9
  def testCallback0(type_checker: TypeCheckerFixture) -> None:
10
- type_checker.make_file(
11
- """
10
+ type_checker.make_file("""
12
11
  from oop_ext.foundation.callback import Callback0
13
12
 
14
13
  c = Callback0()
@@ -16,8 +15,7 @@ def testCallback0(type_checker: TypeCheckerFixture) -> None:
16
15
 
17
16
  def fail(x): pass
18
17
  c.Register(fail)
19
- """
20
- )
18
+ """)
21
19
  result = type_checker.run()
22
20
  result.assert_errors(
23
21
  [
@@ -26,8 +24,7 @@ def testCallback0(type_checker: TypeCheckerFixture) -> None:
26
24
  ]
27
25
  )
28
26
 
29
- type_checker.make_file(
30
- """
27
+ type_checker.make_file("""
31
28
  from oop_ext.foundation.callback import Callback0
32
29
 
33
30
  c = Callback0()
@@ -35,15 +32,13 @@ def testCallback0(type_checker: TypeCheckerFixture) -> None:
35
32
 
36
33
  def ok(): pass
37
34
  c.Register(ok)
38
- """
39
- )
35
+ """)
40
36
  result = type_checker.run()
41
37
  result.assert_ok()
42
38
 
43
39
 
44
40
  def testCallback1(type_checker: TypeCheckerFixture) -> None:
45
- type_checker.make_file(
46
- """
41
+ type_checker.make_file("""
47
42
  from oop_ext.foundation.callback import Callback1
48
43
 
49
44
  c = Callback1[int]()
@@ -55,8 +50,7 @@ def testCallback1(type_checker: TypeCheckerFixture) -> None:
55
50
 
56
51
  def fail2(x: str): pass
57
52
  c.Register(fail2)
58
- """
59
- )
53
+ """)
60
54
  result = type_checker.run()
61
55
  result.assert_errors(
62
56
  [
@@ -71,8 +65,7 @@ def testCallback1(type_checker: TypeCheckerFixture) -> None:
71
65
  ]
72
66
  )
73
67
 
74
- type_checker.make_file(
75
- """
68
+ type_checker.make_file("""
76
69
  from oop_ext.foundation.callback import Callback1
77
70
 
78
71
  c = Callback1[int]()
@@ -80,15 +73,13 @@ def testCallback1(type_checker: TypeCheckerFixture) -> None:
80
73
 
81
74
  def ok(x: int): pass
82
75
  c.Register(ok)
83
- """
84
- )
76
+ """)
85
77
  result = type_checker.run()
86
78
  result.assert_ok()
87
79
 
88
80
 
89
81
  def testPriorityCallback0(type_checker: TypeCheckerFixture) -> None:
90
- type_checker.make_file(
91
- """
82
+ type_checker.make_file("""
92
83
  from oop_ext.foundation.callback import PriorityCallback0
93
84
 
94
85
  c = PriorityCallback0()
@@ -96,8 +87,7 @@ def testPriorityCallback0(type_checker: TypeCheckerFixture) -> None:
96
87
 
97
88
  def fail(x): pass
98
89
  c.Register(fail, priority=2)
99
- """
100
- )
90
+ """)
101
91
  result = type_checker.run()
102
92
  result.assert_errors(
103
93
  [
@@ -106,8 +96,7 @@ def testPriorityCallback0(type_checker: TypeCheckerFixture) -> None:
106
96
  ]
107
97
  )
108
98
 
109
- type_checker.make_file(
110
- """
99
+ type_checker.make_file("""
111
100
  from oop_ext.foundation.callback import PriorityCallback0
112
101
 
113
102
  c = PriorityCallback0()
@@ -115,15 +104,13 @@ def testPriorityCallback0(type_checker: TypeCheckerFixture) -> None:
115
104
 
116
105
  def ok(): pass
117
106
  c.Register(ok, priority=2)
118
- """
119
- )
107
+ """)
120
108
  result = type_checker.run()
121
109
  result.assert_ok()
122
110
 
123
111
 
124
112
  def testPriorityCallback1(type_checker: TypeCheckerFixture) -> None:
125
- type_checker.make_file(
126
- """
113
+ type_checker.make_file("""
127
114
  from oop_ext.foundation.callback import PriorityCallback1
128
115
 
129
116
  c = PriorityCallback1[int]()
@@ -135,8 +122,7 @@ def testPriorityCallback1(type_checker: TypeCheckerFixture) -> None:
135
122
 
136
123
  def fail2(x: str): pass
137
124
  c.Register(fail2, priority=2)
138
- """
139
- )
125
+ """)
140
126
  result = type_checker.run()
141
127
  result.assert_errors(
142
128
  [
@@ -151,8 +137,7 @@ def testPriorityCallback1(type_checker: TypeCheckerFixture) -> None:
151
137
  ]
152
138
  )
153
139
 
154
- type_checker.make_file(
155
- """
140
+ type_checker.make_file("""
156
141
  from oop_ext.foundation.callback import PriorityCallback1
157
142
 
158
143
  c = PriorityCallback1[int]()
@@ -160,8 +145,7 @@ def testPriorityCallback1(type_checker: TypeCheckerFixture) -> None:
160
145
 
161
146
  def ok(x: int): pass
162
147
  c.Register(ok, priority=2)
163
- """
164
- )
148
+ """)
165
149
  result = type_checker.run()
166
150
  result.assert_ok()
167
151
 
@@ -193,8 +177,7 @@ def testAllCallbacksSmokeTest(
193
177
  sig_too_many, args_too_many, types_too_many = gen_signature_and_args(args_count + 1)
194
178
  sig_ok, args_ok, types_ok = gen_signature_and_args(args_count)
195
179
 
196
- type_checker.make_file(
197
- f"""
180
+ type_checker.make_file(f"""
198
181
  from oop_ext.foundation.callback import Callback{args_count}
199
182
 
200
183
  c = Callback{args_count}[{types_ok}]()
@@ -210,8 +193,7 @@ def testAllCallbacksSmokeTest(
210
193
  def ok_func({sig_ok}) -> None: ...
211
194
  c.Register(ok_func)
212
195
  c({args_ok})
213
- """
214
- )
196
+ """)
215
197
  result = type_checker.run()
216
198
  result.assert_errors(
217
199
  [