Skip to content
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

chore: Bump version matrix #298

Merged
merged 1 commit into from
Sep 15, 2024
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.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13-dev"]
steps:
- uses: actions/checkout@v3
- name: Set up Python
Expand Down
2 changes: 0 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
default_language_version:
python: python3.11
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.4.0"
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["setuptools>=67.4.0", "wheel"]
build-backend = "setuptools.build_meta"

[tool.black]
target-version = ["py38"]
target-version = ["py39"]

[tool.pytest.ini_options]
testpaths = ["tests", "src", "docs"]
Expand All @@ -15,7 +15,7 @@ markers = [

[tool.ruff]
fix = true
target-version = "py38"
target-version = "py39"
extend-select = [
# bugbear
"B",
Expand Down
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ classifiers =
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3.13
Development Status :: 5 - Production/Stable
author = Anton Agestam
author_email = [email protected]
Expand All @@ -30,7 +30,7 @@ include_package_data = True
package_dir =
=src
packages = find:
python_requires = >=3.8
python_requires = >=3.9
install_requires =
# typeguard 4.3.0 breaks "intersection" protocols, see linked issue. I didn't figure
# out a way to work around this at the moment, so it needs to be pinned.
Expand Down Expand Up @@ -66,7 +66,7 @@ test =
coverage

[mypy]
python_version = 3.8
python_version = 3.9
show_error_codes = True
pretty = True
files = src, tests
Expand Down
4 changes: 2 additions & 2 deletions src/phantom/_base.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from __future__ import annotations

import abc
from collections.abc import Iterable
from collections.abc import Iterator
from typing import Any
from typing import Callable
from typing import ClassVar
from typing import Generic
from typing import Iterable
from typing import Iterator
from typing import Protocol
from typing import TypeVar
from typing import runtime_checkable
Expand Down
9 changes: 4 additions & 5 deletions src/phantom/_utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
from __future__ import annotations

import types
from collections.abc import MutableMapping
from collections.abc import MutableSequence
from collections.abc import MutableSet
from dataclasses import is_dataclass
from itertools import product
from typing import Final
from typing import MutableMapping
from typing import MutableSequence
from typing import MutableSet
from typing import NewType
from typing import Tuple
from typing import Union

from typing_extensions import TypeAlias
Expand Down Expand Up @@ -39,7 +38,7 @@ def resolve_class_attr(
)


BoundType: TypeAlias = Union[type, Tuple[type, ...]]
BoundType: TypeAlias = Union[type, tuple[type, ...]]


def _is_union(type_: BoundType) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions src/phantom/bounds.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from __future__ import annotations

from collections.abc import Iterable
from collections.abc import Sequence
from typing import Any
from typing import Callable
from typing import Final
from typing import Iterable
from typing import Sequence
from typing import TypeVar
from typing import cast

Expand Down
2 changes: 1 addition & 1 deletion src/phantom/negated.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"""
from __future__ import annotations

from collections.abc import Sequence
from typing import Generic
from typing import Sequence
from typing import TypeVar

from typing_extensions import get_args
Expand Down
2 changes: 1 addition & 1 deletion src/phantom/predicates/boolean.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Iterable
from collections.abc import Iterable
from typing import Literal
from typing import TypeVar

Expand Down
6 changes: 3 additions & 3 deletions src/phantom/predicates/collection.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Container
from typing import Iterable
from typing import Sized
from collections.abc import Container
from collections.abc import Iterable
from collections.abc import Sized
from typing import TypeVar

from . import Predicate
Expand Down
3 changes: 1 addition & 2 deletions src/phantom/predicates/generic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import Tuple
from typing import Union

import typeguard
Expand Down Expand Up @@ -29,7 +28,7 @@ def check(b: object) -> bool:
return check


def of_type(t: Union[type, Tuple[type, ...]]) -> Predicate[object]:
def of_type(t: Union[type, tuple[type, ...]]) -> Predicate[object]:
"""
Create a new predicate that succeeds when its argument is an instance of ``t``.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/phantom/predicates/re.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Pattern
from re import Pattern

from . import Predicate
from ._utils import bind_name
Expand Down
2 changes: 1 addition & 1 deletion src/phantom/re.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class Greeting(Match, pattern=r"^(Hi|Hello)"):
from __future__ import annotations

import re
from re import Pattern
from typing import Any
from typing import Pattern

from . import Phantom
from . import _hypothesis
Expand Down
2 changes: 1 addition & 1 deletion src/phantom/schema.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections.abc import Sequence
from typing import Literal
from typing import Optional
from typing import Sequence

from typing_extensions import TypedDict
from typing_extensions import final
Expand Down
5 changes: 3 additions & 2 deletions src/phantom/sized.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ class SizedStr(str, PhantomBound[str], max=255):
"""
from __future__ import annotations

from collections.abc import Iterable
from collections.abc import Sized

# This is the closest I could find to documentation of _ProtocolMeta.
# https://github.com/python/cpython/commit/74d7f76e2c953fbfdb7ce01b7319d91d471cc5ef
from typing import Any
from typing import Generic
from typing import Iterable
from typing import Protocol
from typing import Sized
from typing import TypeVar
from typing import _ProtocolMeta
from typing import runtime_checkable
Expand Down
2 changes: 1 addition & 1 deletion tests/predicates/test_boolean.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Iterable
from collections.abc import Iterable

import pytest

Expand Down
6 changes: 3 additions & 3 deletions tests/predicates/test_collection.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Container
from typing import Iterable
from typing import Sized
from collections.abc import Container
from collections.abc import Iterable
from collections.abc import Sized

import pytest

Expand Down
10 changes: 6 additions & 4 deletions tests/predicates/test_generic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Tuple
from typing import Type
from typing import Union

import pytest
Expand Down Expand Up @@ -44,13 +42,17 @@ def test_repr_contains_bound_parameter(self):
class TestOfType:
@pytest.mark.parametrize("instance,types", [(1, int), (1, (int, float))])
def test_returns_true_for_instance_of_types(
self, instance: object, types: Union[Type, Tuple[Type, ...]]
self,
instance: object,
types: Union[type, tuple[type, ...]],
) -> None:
assert generic.of_type(types)(instance) is True

@pytest.mark.parametrize("instance,types", [(1, float), ("", (int, float))])
def test_returns_false_for_instance_of_other_type(
self, instance: object, types: Union[Type, Tuple[Type, ...]]
self,
instance: object,
types: Union[type, tuple[type, ...]],
) -> None:
assert generic.of_type(types)(instance) is False

Expand Down
5 changes: 2 additions & 3 deletions tests/predicates/test_interval.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from typing import Tuple

import pytest
from typing_extensions import TypeAlias

from phantom.predicates import interval

from .utils import assert_predicate_name_equals

Boundaries = Tuple[float, float]
Boundaries: TypeAlias = tuple[float, float]
parametrize_inside = pytest.mark.parametrize(
"value, boundaries",
[
Expand Down
9 changes: 0 additions & 9 deletions tests/pydantic/test_schemas.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import sys

import pydantic
import pytest

Expand Down Expand Up @@ -229,13 +227,6 @@ def test_formatted_phone_number_implements_schema(self):
"format": "E.164",
}

@pytest.mark.skipif(
sys.version_info < (3, 9),
reason=(
"Pydantic behavior oddly differs for Python 3.8 and below, where it "
"instead of using the class name, uses the name of the field as title."
),
)
def test_sequence_not_str_implements_schema(self):
assert DataModel.schema()["properties"]["sequence_not_str"] == {
"title": "SequenceNotStr",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_fn.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from __future__ import annotations

from collections.abc import Sequence
from functools import partial
from operator import add
from operator import attrgetter
from operator import itemgetter
from operator import mul
from typing import Callable
from typing import Sequence
from typing import TypeVar

import pytest
Expand Down
2 changes: 1 addition & 1 deletion tests/test_fn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
out: |
main:6: note: Revealed type is "def \(builtins\.str\*?\) -> builtins\.bool\*?"
main:7: error: Argument 1 has incompatible type "int"; expected "str" \[arg-type\]
main:8: error: Argument 1 has incompatible type "List\[Never\]"; expected "str" \[arg-type\]
main:8: error: Argument 1 has incompatible type "list\[Never\]"; expected "str" \[arg-type\]
main:9: note: Revealed type is "builtins.bool\*?"
main:13: note: Revealed type is "builtins.int\*?"
main:17: note: Revealed type is "builtins.str\*?"
Expand Down
Loading