Skip to content

Commit f95e384

Browse files
committed
Remove stale compat code
1 parent 15e01ee commit f95e384

File tree

5 files changed

+17
-38
lines changed

5 files changed

+17
-38
lines changed

src/prefect/plugins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
should be imported when Prefect is imported.
99
"""
1010

11+
from importlib.metadata import EntryPoints, entry_points
1112
from types import ModuleType
1213
from typing import Any, Union
1314

1415
import prefect.settings
15-
from prefect.utilities.compat import EntryPoints, entry_points
1616

1717
_collections: Union[None, dict[str, Union[ModuleType, Exception]]] = None
1818

src/prefect/server/database/dependencies.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Injected database interface dependencies
33
"""
44

5-
import sys
65
from collections.abc import Generator
76
from contextlib import ExitStack, contextmanager
87
from functools import wraps
@@ -233,20 +232,6 @@ def __setattr__(self, name: str, value: Any) -> None:
233232
def __delattr__(self, name: str) -> None:
234233
delattr(self._func, name)
235234

236-
if sys.version_info < (3, 10):
237-
# Python 3.9 inspect.iscoroutinefunction tests are not flexible
238-
# enough to accept this decorator, unfortunately enough. But
239-
# asyncio.iscoroutinefunction does check for a marker object that,
240-
# when found as func._is_coroutine lets you pass the test anyway.
241-
242-
@property
243-
def _is_coroutine(self):
244-
"""Python 3.9 asyncio.iscoroutinefunction work-around"""
245-
from asyncio import coroutines, iscoroutinefunction
246-
247-
if iscoroutinefunction(self._func):
248-
return getattr(coroutines, "_is_coroutine", None)
249-
250235

251236
# Descriptor object responsible for injecting the PrefectDBInterface instance.
252237
# It has no docstring to encourage Python to find the wrapped callable docstring

src/prefect/utilities/compat.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
"""
22
Utilities for Python version compatibility
33
"""
4-
# Please organize additions to this file by version
54

6-
import sys
5+
# Please organize additions to this file by version
6+
import warnings
7+
import importlib.metadata
8+
from importlib.metadata import (
9+
EntryPoint as EntryPoint,
10+
EntryPoints as EntryPoints,
11+
entry_points as entry_points,
12+
)
713

8-
if sys.version_info < (3, 10):
9-
import importlib_metadata as importlib_metadata
10-
from importlib_metadata import (
11-
EntryPoint as EntryPoint,
12-
EntryPoints as EntryPoints,
13-
entry_points as entry_points,
14-
)
15-
else:
16-
import importlib.metadata
17-
from importlib.metadata import (
18-
EntryPoint as EntryPoint,
19-
EntryPoints as EntryPoints,
20-
entry_points as entry_points,
21-
)
14+
importlib_metadata = importlib.metadata
2215

23-
importlib_metadata = importlib.metadata
16+
warnings.warn(
17+
"The prefect.utilities.compat module is deprecated. "
18+
"Use importlib.metadata directly instead.",
19+
DeprecationWarning,
20+
stacklevel=2,
21+
)

src/prefect/utilities/importtools.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ def to_qualified_name(obj: Any) -> str:
4040
Returns:
4141
str: the qualified name
4242
"""
43-
if sys.version_info < (3, 10):
44-
# These attributes are only available in Python 3.10+
45-
if isinstance(obj, (classmethod, staticmethod)):
46-
obj = obj.__func__
4743
return obj.__module__ + "." + obj.__qualname__
4844

4945

tests/test_plugins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
from importlib.metadata import EntryPoints
12
from unittest.mock import Mock, patch
23

34
import pytest
45

56
import prefect.plugins
67
from prefect.plugins import load_prefect_collections, safe_load_entrypoints
78
from prefect.settings import PREFECT_DEBUG_MODE, temporary_settings
8-
from prefect.utilities.compat import EntryPoints
99

1010

1111
@pytest.fixture(autouse=True)

0 commit comments

Comments
 (0)