From b7ee00da2cfa8208c47812fb657392e8b88f620c Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 20 Aug 2024 13:46:39 -0400 Subject: [PATCH] Remove ABCMeta metaclass, keep abstractmethods --- newsfragments/4579.bugfix.rst | 1 + pkg_resources/__init__.py | 3 +-- setuptools/__init__.py | 4 ++-- setuptools/command/setopt.py | 3 +-- setuptools/sandbox.py | 3 +-- 5 files changed, 6 insertions(+), 8 deletions(-) create mode 100644 newsfragments/4579.bugfix.rst diff --git a/newsfragments/4579.bugfix.rst b/newsfragments/4579.bugfix.rst new file mode 100644 index 0000000000..bd5ad8c203 --- /dev/null +++ b/newsfragments/4579.bugfix.rst @@ -0,0 +1 @@ +Remove `abc.ABCMeta` metaclass from abstract classes. `pypa/setuptools#4503 `_ had an unintended consequence of causing potential ``TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases`` -- by :user:`Avasam` diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 8bbf249371..76aa5e77ba 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -23,7 +23,6 @@ from __future__ import annotations import sys -from abc import ABC if sys.version_info < (3, 8): # noqa: UP036 # Check for unsupported versions raise RuntimeError("Python 3.8 or later is required") @@ -306,7 +305,7 @@ def get_supported_platform(): ] -class ResolutionError(Exception, ABC): +class ResolutionError(Exception): """Abstract base for dependency resolution errors""" def __repr__(self): diff --git a/setuptools/__init__.py b/setuptools/__init__.py index 73de2a03d3..1d3156ff10 100644 --- a/setuptools/__init__.py +++ b/setuptools/__init__.py @@ -6,7 +6,7 @@ import os import re import sys -from abc import ABC, abstractmethod +from abc import abstractmethod from typing import TYPE_CHECKING, TypeVar, overload sys.path.extend(((vendor_path := os.path.join(os.path.dirname(os.path.dirname(__file__)), 'setuptools', '_vendor')) not in sys.path) * [vendor_path]) # fmt: skip @@ -120,7 +120,7 @@ def setup(**attrs): _Command = monkey.get_unpatched(distutils.core.Command) -class Command(_Command, ABC): +class Command(_Command): """ Setuptools internal actions are organized using a *command design pattern*. This means that each action (or group of closely related actions) executed during diff --git a/setuptools/command/setopt.py b/setuptools/command/setopt.py index b2653bd466..e351af22f0 100644 --- a/setuptools/command/setopt.py +++ b/setuptools/command/setopt.py @@ -1,6 +1,5 @@ import configparser import os -from abc import ABC from .. import Command from ..unicode_utils import _cfg_read_utf8_with_fallback @@ -70,7 +69,7 @@ def edit_config(filename, settings, dry_run=False): opts.write(f) -class option_base(Command, ABC): +class option_base(Command): """Abstract base class for commands that mess with config files""" user_options = [ diff --git a/setuptools/sandbox.py b/setuptools/sandbox.py index 9a101b7137..7d545f1004 100644 --- a/setuptools/sandbox.py +++ b/setuptools/sandbox.py @@ -11,7 +11,6 @@ import sys import tempfile import textwrap -from abc import ABC import pkg_resources from pkg_resources import working_set @@ -263,7 +262,7 @@ def run_setup(setup_script, args): # Normal exit, just return -class AbstractSandbox(ABC): +class AbstractSandbox: """Wrap 'os' module and 'open()' builtin for virtualizing setup scripts""" _active = False