Skip to content

Commit

Permalink
Add better notes for what's needded before python 3.14 support
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeshardmind committed Jan 19, 2025
1 parent e6545f7 commit 8a3701e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions _misc/_ensure_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Do NOT add `from __future__ import annotations` to this file.

import ast
import inspect
Expand All @@ -21,6 +22,7 @@
_cycle_blocked = False


#: PYUPDATE: py3.14, annotationslib based check as well.
def ensure_annotations[T: type | FunctionType](f: T) -> T:
"""Ensure annotations are runtime valid.
Expand Down
14 changes: 14 additions & 0 deletions src/async_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
import sys

vi = sys.version_info

# Check use of concurrent.futures.Future before extending this version.
# update `_misc._ensure_annotations.py` before extending this version.
if (vi.major, vi.minor) > (3, 13):
msg = """This library is not tested for use on python versions above 3.13
This library relies on a few internal details that are not safe to rely upon
Expand All @@ -23,6 +26,17 @@
if os.getenv("ASYNC_UTILS_UNCHECKED_PY_VER", ""):
import logging

msg += """\nThis is not neccessarily broken, but if you encounter an
issue with it, please be aware that the library has not actively
chosen to support the python version you have opted into using this on
*yet*. If you encounter an issue with it, please do still report it.
"""

logging.getLogger(__file__).warning(msg)
else:
msg += """\nYou can change this error to a warning if you are sure it is
safe and are willing to take the risk on yourself before I have verified
it by setting the environment variable `ASYNC_UTILS_UNCHECKED_PY_VER`
to a non-empty value.
"""
raise RuntimeError(msg)
2 changes: 1 addition & 1 deletion src/async_utils/gen_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from __future__ import annotations

import asyncio
import concurrent.futures as cf
import concurrent.futures as cf #: PYUPDATE: py3.14, check cf.Future use
from collections.abc import AsyncGenerator, Callable, Generator
from threading import Event

Expand Down

0 comments on commit 8a3701e

Please sign in to comment.