Skip to content

Commit b9a316e

Browse files
authored
📌 Use Cython < v3 (#5845)
1 parent 25c99b5 commit b9a316e

File tree

6 files changed

+7
-13
lines changed

6 files changed

+7
-13
lines changed

‎.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ jobs:
380380
CIBW_BUILD: 'cp3${{ matrix.python-version }}-*'
381381
CIBW_SKIP: '*-win32'
382382
CIBW_PLATFORM: '${{ matrix.platform || matrix.os }}'
383-
CIBW_BEFORE_BUILD: 'pip install -U cython'
383+
CIBW_BEFORE_BUILD: 'pip install -U "cython<3"'
384384
CIBW_TEST_REQUIRES: 'pytest==6.2.5 pytest-mock==3.6.1'
385385
CIBW_TEST_COMMAND: 'pytest {project}/tests'
386386
CIBW_MANYLINUX_X86_64_IMAGE: 'manylinux2014'

‎changes/5845-lig.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Discourage usage of Cython 3 with Pydantic 1.x.

‎docs/install.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ conda install pydantic -c conda-forge
2222
By default `pip install` provides optimized binaries via [PyPI](https://pypi.org/project/pydantic/#files) for Linux, MacOS and 64bit Windows.
2323

2424

25-
If you're installing manually, install `cython` before installing *pydantic* and compilation should happen automatically.
25+
If you're installing manually, install `cython<3` (Pydantic 1.x is incompatible with Cython v3 and above) before installing *pydantic* and compilation should happen automatically.
2626

2727
To test if *pydantic* is compiled run:
2828

‎pydantic/_hypothesis_plugin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
#
4747
# conlist() and conset() are unsupported for now, because the workarounds for
4848
# Cython and Hypothesis to handle parametrized generic types are incompatible.
49-
# Once Cython can support 'normal' generics we'll revisit this.
49+
# We are rethinking Hypothesis compatibility in Pydantic v2.
5050

5151
# Emails
5252
try:

‎pydantic/config.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ class Extra(str, Enum):
3838

3939

4040
# https://github.com/cython/cython/issues/4003
41-
# Will be fixed with Cython 3 but still in alpha right now
41+
# Fixed in Cython 3 and Pydantic v1 won't support Cython 3.
42+
# Pydantic v2 doesn't depend on Cython at all.
4243
if not compiled:
4344
from typing_extensions import TypedDict
4445

‎pydantic/typing.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,7 @@ def is_union(tp: Optional[Type[Any]]) -> bool:
252252
WithArgsTypes = (typing._GenericAlias, types.GenericAlias, types.UnionType)
253253

254254

255-
if sys.version_info < (3, 9):
256-
StrPath = Union[str, PathLike]
257-
else:
258-
StrPath = Union[str, PathLike]
259-
# TODO: Once we switch to Cython 3 to handle generics properly
260-
# (https://github.com/cython/cython/issues/2753), use following lines instead
261-
# of the one above
262-
# # os.PathLike only becomes subscriptable from Python 3.9 onwards
263-
# StrPath = Union[str, PathLike[str]]
255+
StrPath = Union[str, PathLike]
264256

265257

266258
if TYPE_CHECKING:

0 commit comments

Comments
 (0)