Skip to content

Commit 9325cca

Browse files
ref(compat): Remove unused with_metaclass helper (#8153)
### Description Removes `with_metaclass()` from `sentry_sdk/_compat.py`. Nothing on `major/3.0` uses it anymore. It's a Python 2 / `six`-style helper for declaring a metaclass across Python versions; on Python 3 you just write `class Foo(metaclass=Meta)`. Its only caller was `class Hub(with_metaclass(HubMeta))` in `sentry_sdk/hub.py`. #6919 ("Drop hub related code in new major") deleted `Hub` and the import, but left the helper behind. With the helper gone, the `TYPE_CHECKING` block in `_compat.py` (`Any`, `TypeVar`, `T`) is unused too, so it's removed as well. `T` wasn't used before this change either. **Evidence** - On `major/3.0`, `git grep with_metaclass` matches only the definition. There are no callers in `sentry_sdk`, `tests`, `scripts` or `docs`. - Nothing imports `T` or `Any` from `sentry_sdk._compat`. - #6091 and #7421 (against `master`) proposed the same removal as part of larger Python 2 cleanups. Both were closed without being merged, one for inactivity. Neither raised an objection to this change. On `master`, `Hub` still uses the helper, so this only applies to `major/3.0`. `_compat` is a private module, so this doesn't touch the public API. #### Issues n/a <!-- junior-request-attribution:start --> via **Ivana Kellyer**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AC0BTREZTS2Z%3A1793270559.842119 --> -- [View Junior Session](https://junior-prod.sentry.dev/conversations/slack%3AC0BTREZTS2Z%3A1793270559.842119) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0BTREZTS2Z%3A1793270559.842119/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Ivana Kellyer <ivana.kellyer@sentry.io>
1 parent 20df0da commit 9325cca

1 file changed

Lines changed: 0 additions & 15 deletions

File tree

‎sentry_sdk/_compat.py‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,11 @@
11
import sys
2-
from typing import TYPE_CHECKING
3-
4-
if TYPE_CHECKING:
5-
from typing import Any, TypeVar
6-
7-
T = TypeVar("T")
8-
92

103
PY37 = sys.version_info[0] == 3 and sys.version_info[1] >= 7
114
PY38 = sys.version_info[0] == 3 and sys.version_info[1] >= 8
125
PY310 = sys.version_info[0] == 3 and sys.version_info[1] >= 10
136
PY311 = sys.version_info[0] == 3 and sys.version_info[1] >= 11
147

158

16-
def with_metaclass(meta: "Any", *bases: "Any") -> "Any":
17-
class MetaClass(type):
18-
def __new__(metacls: "Any", name: "Any", this_bases: "Any", d: "Any") -> "Any":
19-
return meta(name, bases, d)
20-
21-
return type.__new__(MetaClass, "temporary_class", (), {})
22-
23-
249
def check_uwsgi_thread_support() -> bool:
2510
# We check two things here:
2611
#

0 commit comments

Comments
 (0)