Skip to content

Commit 32c14aa

Browse files
committed
Removed deprecated support for Distribution subclasses not implementing abstract methods.
1 parent b76931d commit 32c14aa

File tree

4 files changed

+2
-37
lines changed

4 files changed

+2
-37
lines changed

docs/conf.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,4 @@
6969
('py:class', 'importlib_metadata._meta._T'),
7070
# Workaround for #435
7171
('py:class', '_T'),
72-
# Other workarounds
73-
('py:class', 'importlib_metadata.DeprecatedNonAbstract'),
7472
]

importlib_metadata/__init__.py

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import pathlib
1313
import operator
1414
import textwrap
15-
import warnings
1615
import functools
1716
import itertools
1817
import posixpath
@@ -334,27 +333,7 @@ def __repr__(self) -> str:
334333
return f'<FileHash mode: {self.mode} value: {self.value}>'
335334

336335

337-
class DeprecatedNonAbstract:
338-
# Required until Python 3.14
339-
def __new__(cls, *args, **kwargs):
340-
all_names = {
341-
name for subclass in inspect.getmro(cls) for name in vars(subclass)
342-
}
343-
abstract = {
344-
name
345-
for name in all_names
346-
if getattr(getattr(cls, name), '__isabstractmethod__', False)
347-
}
348-
if abstract:
349-
warnings.warn(
350-
f"Unimplemented abstract methods {abstract}",
351-
DeprecationWarning,
352-
stacklevel=2,
353-
)
354-
return super().__new__(cls)
355-
356-
357-
class Distribution(DeprecatedNonAbstract):
336+
class Distribution(metaclass=abc.ABCMeta):
358337
"""
359338
An abstract Python distribution package.
360339

newsfragments/+8256a9d7.removal.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Removed deprecated support for Distribution subclasses not implementing abstract methods.

tests/test_main.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
import re
22
import pickle
33
import unittest
4-
import warnings
54
import importlib
65
import importlib_metadata
7-
import contextlib
86
from .compat.py39 import os_helper
97

108
import pyfakefs.fake_filesystem_unittest as ffs
119

1210
from . import fixtures
13-
from ._context import suppress
1411
from ._path import Symlink
1512
from importlib_metadata import (
1613
Distribution,
@@ -25,13 +22,6 @@
2522
)
2623

2724

28-
@contextlib.contextmanager
29-
def suppress_known_deprecation():
30-
with warnings.catch_warnings(record=True) as ctx:
31-
warnings.simplefilter('default', category=DeprecationWarning)
32-
yield ctx
33-
34-
3525
class BasicTests(fixtures.DistInfoPkg, unittest.TestCase):
3626
version_pattern = r'\d+\.\d+(\.\d)?'
3727

@@ -56,9 +46,6 @@ def test_package_not_found_mentions_metadata(self):
5646

5747
assert "metadata" in str(ctx.exception)
5848

59-
# expected to fail until ABC is enforced
60-
@suppress(AssertionError)
61-
@suppress_known_deprecation()
6249
def test_abc_enforced(self):
6350
with self.assertRaises(TypeError):
6451
type('DistributionSubclass', (Distribution,), {})()

0 commit comments

Comments
 (0)