Skip to content

Commit 52e9a53

Browse files
authored
drop pypy3.9 support, add pypy3.11 support (#1726)
1 parent 4e85411 commit 52e9a53

File tree

7 files changed

+26
-22
lines changed

7 files changed

+26
-22
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ jobs:
7171
- '3.13t'
7272
- '3.14'
7373
- '3.14t'
74-
- 'pypy3.9'
7574
- 'pypy3.10'
75+
- 'pypy3.11'
7676

7777
runs-on: ubuntu-latest
7878

@@ -424,7 +424,7 @@ jobs:
424424
- os: linux
425425
manylinux: auto
426426
target: x86_64
427-
interpreter: pypy3.9 pypy3.10 pypy3.11
427+
interpreter: pypy3.10 pypy3.11
428428

429429
# musllinux
430430
- os: linux
@@ -444,15 +444,15 @@ jobs:
444444
target: x86_64
445445
- os: macos
446446
target: aarch64
447-
interpreter: 3.9 pypy3.9 pypy3.10 pypy3.11
447+
interpreter: 3.9 pypy3.10 pypy3.11
448448

449449
# windows;
450450
# x86_64 pypy builds are not PGO optimized
451451
# i686 not supported by pypy
452452
# aarch64 only 3.11 and up, also not PGO optimized
453453
- os: windows
454454
target: x86_64
455-
interpreter: pypy3.9 pypy3.10 pypy3.11
455+
interpreter: pypy3.10 pypy3.11
456456
- os: windows
457457
target: i686
458458
python-architecture: x86
@@ -483,7 +483,7 @@ jobs:
483483
with:
484484
target: ${{ matrix.target }}
485485
manylinux: ${{ matrix.manylinux }}
486-
args: --release --out dist --interpreter ${{ matrix.interpreter || '3.9 3.10 3.11 3.12 3.13 3.14 pypy3.9 pypy3.10 pypy3.11' }}
486+
args: --release --out dist --interpreter ${{ matrix.interpreter || '3.9 3.10 3.11 3.12 3.13 3.14 pypy3.10 pypy3.11' }}
487487
rust-toolchain: stable
488488
docker-options: -e CI
489489

src/input/return_enums.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use pyo3::exceptions::PyTypeError;
1111
use pyo3::ffi;
1212
use pyo3::intern;
1313
use pyo3::prelude::*;
14-
#[cfg(not(PyPy))]
1514
use pyo3::types::PyFunction;
1615
use pyo3::types::{PyBytes, PyComplex, PyFloat, PyFrozenSet, PyIterator, PyMapping, PySet, PyString};
1716

@@ -348,17 +347,9 @@ pub(crate) fn iterate_attributes<'a, 'py>(
348347
// the PyFunction::is_type_of(attr) catches `staticmethod`, but also any other function,
349348
// I think that's better than including static methods in the yielded attributes,
350349
// if someone really wants fields, they can use an explicit field, or a function to modify input
351-
#[cfg(not(PyPy))]
352350
if !is_bound && !attr.is_instance_of::<PyFunction>() {
353351
return Some(Ok((name, attr)));
354352
}
355-
// MASSIVE HACK! PyFunction doesn't exist for PyPy,
356-
// is_instance_of::<PyFunction> crashes with a null pointer, hence this hack, see
357-
// https://github.com/pydantic/pydantic-core/pull/161#discussion_r917257635
358-
#[cfg(PyPy)]
359-
if !is_bound && attr.get_type().to_string() != "<class 'function'>" {
360-
return Some(Ok((name, attr)));
361-
}
362353
}
363354
}
364355
None

src/tools.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,6 @@ pub fn truncate_safe_repr(v: &Bound<'_, PyAny>, max_len: Option<usize>) -> Strin
129129
}
130130

131131
pub fn extract_i64(v: &Bound<'_, PyAny>) -> Option<i64> {
132-
#[cfg(PyPy)]
133-
if !v.is_instance_of::<pyo3::types::PyInt>() {
134-
// PyPy used __int__ to cast floats to ints after CPython removed it,
135-
// see https://github.com/pypy/pypy/issues/4949
136-
//
137-
// Can remove this after PyPy 7.3.17 is released
138-
return None;
139-
}
140132
v.extract().ok()
141133
}
142134

tests/validators/test_arguments.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import platform
12
import re
23
import sys
34
from functools import wraps
@@ -1137,6 +1138,9 @@ def test_invalid_schema():
11371138
)
11381139

11391140

1141+
@pytest.mark.xfail(
1142+
platform.python_implementation() == 'PyPy' and sys.version_info[:2] == (3, 11), reason='pypy 3.11 type formatting'
1143+
)
11401144
def test_error_display(pydantic_version):
11411145
v = SchemaValidator(
11421146
core_schema.arguments_schema(

tests/validators/test_definitions_recursive.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import datetime
22
import platform
3+
import sys
34
from dataclasses import dataclass
45
from typing import Optional
56

@@ -752,6 +753,9 @@ def test_many_uses_of_ref():
752753
assert v.validate_python(long_input) == long_input
753754

754755

756+
@pytest.mark.xfail(
757+
platform.python_implementation() == 'PyPy' and sys.version_info[:2] == (3, 11), reason='pypy 3.11 type formatting'
758+
)
755759
def test_error_inside_definition_wrapper():
756760
with pytest.raises(SchemaError) as exc_info:
757761
SchemaValidator(

tests/validators/test_string.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import platform
12
import re
23
import sys
34
from decimal import Decimal
@@ -172,6 +173,10 @@ def test_str_constrained_config():
172173

173174
@pytest.mark.parametrize('engine', [None, 'rust-regex', 'python-re'])
174175
def test_invalid_regex(engine):
176+
if platform.python_implementation() == 'PyPy' and sys.version_info[:2] == (3, 11):
177+
# pypy 3.11 type formatting
178+
pytest.xfail()
179+
175180
# TODO uncomment and fix once #150 is done
176181
# with pytest.raises(SchemaError) as exc_info:
177182
# SchemaValidator({'type': 'str', 'pattern': 123})
@@ -343,6 +348,9 @@ def test_coerce_numbers_to_str_from_json(number: str, expected_str: str) -> None
343348

344349

345350
@pytest.mark.parametrize('mode', (None, 'schema', 'config'))
351+
@pytest.mark.xfail(
352+
platform.python_implementation() == 'PyPy' and sys.version_info[:2] == (3, 11), reason='pypy 3.11 type formatting'
353+
)
346354
def test_backtracking_regex_rust_unsupported(mode) -> None:
347355
pattern = r'r(#*)".*?"\1'
348356

tests/validators/test_union.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import platform
2+
import sys
13
from dataclasses import dataclass
24
from datetime import date, time
35
from enum import Enum, IntEnum
@@ -231,6 +233,9 @@ def test_union_list_bool_int():
231233
]
232234

233235

236+
@pytest.mark.xfail(
237+
platform.python_implementation() == 'PyPy' and sys.version_info[:2] == (3, 11), reason='pypy 3.11 type formatting'
238+
)
234239
def test_empty_choices():
235240
msg = r'Error building "union" validator:\s+SchemaError: One or more union choices required'
236241
with pytest.raises(SchemaError, match=msg):

0 commit comments

Comments
 (0)