Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14.0-alpha.6"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14.0-beta.1"]
os: ["ubuntu-latest", "windows-latest", "macos-latest"]


Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Élie Goudout
Copyright (c) 2024—2025 Élie Goudout

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
![OS Independant](https://img.shields.io/badge/OS_Independant-%E2%9C%93-blue)
[![python versions](https://img.shields.io/badge/python-3.10%20|%203.11%20|%203.12%20|%203.13%20|%203.14.0a6-blue)](https://devguide.python.org/versions/)
[![python versions](https://img.shields.io/badge/python-3.10%20|%203.11%20|%203.12%20|%203.13%20|%203.14.0b1-blue)](https://devguide.python.org/versions/)
[![license MIT](https://img.shields.io/github/license/eliegoudout/paramclasses)](https://opensource.org/licenses/MIT)
[![pypi](https://img.shields.io/pypi/v/paramclasses)](https://pypi.org/project/paramclasses/)
[![pipeline status](https://github.com/eliegoudout/paramclasses/actions/workflows/ci.yml/badge.svg)](https://github.com/eliegoudout/paramclasses/actions)
Expand Down
31 changes: 13 additions & 18 deletions paramclasses/paramclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,30 +150,25 @@ def _get_namespace_annotations(
namespace: dict[str, object],
) -> dict[str, object]: # pragma: no cover
"""Get annotations from a namespace dict, 3.14 compatible."""
__annotations__ = cast("dict[str, object] | None", namespace.get("__annotations__"))

if sys.version_info < (3, 14):
return {} if __annotations__ is None else __annotations__
return cast("dict[str, object]", namespace.get("__annotations__", {}))

# For python >= 3.14
# https://discuss.python.org/t/python-3-14-metaclasses-interact-with-annotations-from-namespace-dict/87010
__annotate__ = namespace.get("__annotate__")

if __annotations__ is None:
if __annotate__ is None:
return {}

from annotationlib import ( # type: ignore[import-not-found]
Format,
call_annotate_function,
)
# https://docs.python.org/3.14/library/annotationlib.html#using-annotations-in-a-metaclass
if "__annotations__" in namespace: # from __future__ import annotations
return cast("dict[str, object]", namespace["__annotations__"])

return call_annotate_function(__annotate__, Format.FORWARDREF)
from annotationlib import ( # type: ignore[import-not-found]
Format,
call_annotate_function,
get_annotate_from_class_namespace,
)

if __annotate__ is not None:
namespace["__annotate__"] = None
annotate = get_annotate_from_class_namespace(namespace)
if annotate is None:
return {}

return __annotations__
return call_annotate_function(annotate, format=Format.FORWARDREF)


def _update_while_checking_consistency(orig: dict, update: MappingProxyType) -> None:
Expand Down
Loading