Skip to content

drop pypy3.9 support #1726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ jobs:
- '3.12'
- '3.13'
- '3.13t'
- 'pypy3.9'
- 'pypy3.10'
- 'pypy3.11'

runs-on: ubuntu-latest

Expand Down Expand Up @@ -424,7 +424,7 @@ jobs:
- os: linux
manylinux: auto
target: x86_64
interpreter: pypy3.9 pypy3.10 pypy3.11
interpreter: pypy3.10 pypy3.11

# musllinux
- os: linux
Expand All @@ -444,15 +444,15 @@ jobs:
target: x86_64
- os: macos
target: aarch64
interpreter: 3.9 pypy3.9 pypy3.10 pypy3.11
interpreter: 3.9 pypy3.10 pypy3.11

# windows;
# x86_64 pypy builds are not PGO optimized
# i686 not supported by pypy
# aarch64 only 3.11 and up, also not PGO optimized
- os: windows
target: x86_64
interpreter: pypy3.9 pypy3.10 pypy3.11
interpreter: pypy3.10 pypy3.11
- os: windows
target: i686
python-architecture: x86
Expand Down Expand Up @@ -486,7 +486,7 @@ jobs:
with:
target: ${{ matrix.target }}
manylinux: ${{ matrix.manylinux }}
args: --release --out dist --interpreter ${{ matrix.interpreter || '3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10 pypy3.11' }}
args: --release --out dist --interpreter ${{ matrix.interpreter || '3.9 3.10 3.11 3.12 3.13 pypy3.10 pypy3.11' }}
rust-toolchain: stable
docker-options: -e CI

Expand Down
9 changes: 0 additions & 9 deletions src/input/return_enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use pyo3::exceptions::PyTypeError;
use pyo3::ffi;
use pyo3::intern;
use pyo3::prelude::*;
#[cfg(not(PyPy))]
use pyo3::types::PyFunction;
use pyo3::types::{PyBytes, PyComplex, PyFloat, PyFrozenSet, PyIterator, PyMapping, PySet, PyString};

Expand Down Expand Up @@ -348,17 +347,9 @@ pub(crate) fn iterate_attributes<'a, 'py>(
// the PyFunction::is_type_of(attr) catches `staticmethod`, but also any other function,
// I think that's better than including static methods in the yielded attributes,
// if someone really wants fields, they can use an explicit field, or a function to modify input
#[cfg(not(PyPy))]
if !is_bound && !attr.is_instance_of::<PyFunction>() {
return Some(Ok((name, attr)));
}
// MASSIVE HACK! PyFunction doesn't exist for PyPy,
// is_instance_of::<PyFunction> crashes with a null pointer, hence this hack, see
// https://github.com/pydantic/pydantic-core/pull/161#discussion_r917257635
#[cfg(PyPy)]
if !is_bound && attr.get_type().to_string() != "<class 'function'>" {
return Some(Ok((name, attr)));
}
}
}
None
Expand Down
8 changes: 0 additions & 8 deletions src/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,6 @@ pub fn truncate_safe_repr(v: &Bound<'_, PyAny>, max_len: Option<usize>) -> Strin
}

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

Expand Down
4 changes: 4 additions & 0 deletions tests/validators/test_arguments.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import platform
import re
import sys
from functools import wraps
Expand Down Expand Up @@ -1137,6 +1138,9 @@ def test_invalid_schema():
)


@pytest.mark.xfail(
platform.python_implementation() == 'PyPy' and sys.version_info[:2] == (3, 11), reason='pypy 3.11 type formatting'
)
def test_error_display(pydantic_version):
v = SchemaValidator(
core_schema.arguments_schema(
Expand Down
4 changes: 4 additions & 0 deletions tests/validators/test_definitions_recursive.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import datetime
import platform
import sys
from dataclasses import dataclass
from typing import Optional

Expand Down Expand Up @@ -752,6 +753,9 @@ def test_many_uses_of_ref():
assert v.validate_python(long_input) == long_input


@pytest.mark.xfail(
platform.python_implementation() == 'PyPy' and sys.version_info[:2] == (3, 11), reason='pypy 3.11 type formatting'
)
def test_error_inside_definition_wrapper():
with pytest.raises(SchemaError) as exc_info:
SchemaValidator(
Expand Down
8 changes: 8 additions & 0 deletions tests/validators/test_string.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import platform
import re
import sys
from decimal import Decimal
Expand Down Expand Up @@ -172,6 +173,10 @@ def test_str_constrained_config():

@pytest.mark.parametrize('engine', [None, 'rust-regex', 'python-re'])
def test_invalid_regex(engine):
if platform.python_implementation() == 'PyPy' and sys.version_info[:2] == (3, 11):
# pypy 3.11 type formatting
pytest.xfail()

# TODO uncomment and fix once #150 is done
# with pytest.raises(SchemaError) as exc_info:
# SchemaValidator({'type': 'str', 'pattern': 123})
Expand Down Expand Up @@ -343,6 +348,9 @@ def test_coerce_numbers_to_str_from_json(number: str, expected_str: str) -> None


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

Expand Down
5 changes: 5 additions & 0 deletions tests/validators/test_union.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import platform
import sys
from dataclasses import dataclass
from datetime import date, time
from enum import Enum, IntEnum
Expand Down Expand Up @@ -247,6 +249,9 @@ def test_no_choices(pydantic_version):
]


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