Skip to content

Commit 9e4bad4

Browse files
committed
address ruff upgrade
1 parent 5709824 commit 9e4bad4

File tree

12 files changed

+32
-26
lines changed

12 files changed

+32
-26
lines changed

hypothesis-python/src/hypothesis/extra/ghostwriter.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@
9090
from typing import (
9191
Any,
9292
Callable,
93-
DefaultDict,
9493
ForwardRef,
9594
NamedTuple,
9695
Optional,
@@ -886,7 +885,7 @@ def _make_test_body(
886885
def _annotate_args(
887886
argnames: Iterable[str], funcs: Iterable[Callable], imports: ImportSet
888887
) -> Iterable[str]:
889-
arg_parameters: DefaultDict[str, set[Any]] = defaultdict(set)
888+
arg_parameters: defaultdict[str, set[Any]] = defaultdict(set)
890889
for func in funcs:
891890
try:
892891
params = tuple(get_signature(func, eval_str=True).parameters.values())

hypothesis-python/src/hypothesis/internal/conjecture/datatree.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
# obtain one at https://mozilla.org/MPL/2.0/.
1010

1111
import math
12-
from collections.abc import Generator
12+
from collections.abc import Generator, Set
1313
from random import Random
14-
from typing import TYPE_CHECKING, AbstractSet, Final, Optional, Union, cast
14+
from typing import TYPE_CHECKING, Final, Optional, Union, cast
1515

1616
import attr
1717

@@ -431,7 +431,7 @@ class TreeNode:
431431
is_exhausted: bool = attr.ib(default=False, init=False)
432432

433433
@property
434-
def forced(self) -> AbstractSet[int]:
434+
def forced(self) -> Set[int]:
435435
if not self.__forced:
436436
return EMPTY
437437
return self.__forced

hypothesis-python/src/hypothesis/internal/conjecture/engine.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from datetime import timedelta
2121
from enum import Enum
2222
from random import Random, getrandbits
23-
from typing import Callable, Final, List, Literal, NoReturn, Optional, Union, cast
23+
from typing import Callable, Final, Literal, NoReturn, Optional, Union, cast
2424

2525
from hypothesis import HealthCheck, Phase, Verbosity, settings as Settings
2626
from hypothesis._settings import local_settings, note_deprecation
@@ -109,7 +109,7 @@ class HealthCheckState:
109109
valid_examples: int = field(default=0)
110110
invalid_examples: int = field(default=0)
111111
overrun_examples: int = field(default=0)
112-
draw_times: "defaultdict[str, List[float]]" = field(
112+
draw_times: defaultdict[str, list[float]] = field(
113113
default_factory=lambda: defaultdict(list)
114114
)
115115

hypothesis-python/src/hypothesis/internal/conjecture/providers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ def span_start(self, label: int, /) -> None: # noqa: B027 # non-abstract noop
651651
internally.
652652
"""
653653

654-
def span_end(self, discard: bool, /) -> None: # noqa: B027, FBT001
654+
def span_end(self, discard: bool, /) -> None: # noqa: B027
655655
"""Marks the end of a semantically meaningful span of choices.
656656
657657
``discard`` is ``True`` when the draw was filtered out or otherwise marked

hypothesis-python/src/hypothesis/strategies/_internal/types.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -949,25 +949,25 @@ def resolve_Iterator(thing):
949949
return st.iterables(st.from_type(thing.__args__[0]))
950950

951951

952-
@register(typing.Counter, st.builds(collections.Counter))
952+
@register(collections.Counter, st.builds(collections.Counter))
953953
def resolve_Counter(thing):
954954
return st.dictionaries(
955955
keys=st.from_type(thing.__args__[0]),
956956
values=st.integers(),
957957
).map(collections.Counter)
958958

959959

960-
@register(typing.Deque, st.builds(collections.deque))
960+
@register(collections.deque, st.builds(collections.deque))
961961
def resolve_deque(thing):
962962
return st.lists(st.from_type(thing.__args__[0])).map(collections.deque)
963963

964964

965-
@register(typing.ChainMap, st.builds(dict).map(collections.ChainMap))
965+
@register(collections.ChainMap, st.builds(dict).map(collections.ChainMap))
966966
def resolve_ChainMap(thing):
967967
return resolve_Dict(thing).map(collections.ChainMap)
968968

969969

970-
@register(typing.OrderedDict, st.builds(dict).map(collections.OrderedDict))
970+
@register(collections.OrderedDict, st.builds(dict).map(collections.OrderedDict))
971971
def resolve_OrderedDict(thing):
972972
return resolve_Dict(thing).map(collections.OrderedDict)
973973

hypothesis-python/src/hypothesis/vendor/pretty.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ def _repr_pretty_(self, p, cycle):
8383

8484
from hypothesis.control import BuildContext
8585

86-
# ruff: noqa: FBT001
87-
8886
T = TypeVar("T")
8987
PrettyPrintFunction: "TypeAlias" = Callable[[Any, "RepresentationPrinter", bool], None]
9088

hypothesis-python/tests/cover/test_lookup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
)
5555
from tests.common.utils import fails_with, temp_registered
5656

57+
# we'll continue testing the typing variants until their removal from the stdlib
58+
# ruff: noqa: UP006, UP035
59+
5760
sentinel = object()
5861
BUILTIN_TYPES = tuple(
5962
v

hypothesis-python/tests/cover/test_type_lookup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import typing
1515
from collections.abc import Sequence
1616
from inspect import Parameter as P, Signature
17-
from typing import Callable, Generic, List as _List, TypeVar, Union
17+
from typing import Callable, Generic, TypeVar, Union
1818

1919
import pytest
2020

@@ -358,7 +358,7 @@ def test_generic_origin_with_type_args(generic, strategy):
358358
list,
359359
Sequence,
360360
# you can register types with all generic parameters
361-
_List[T],
361+
list[T],
362362
getattr(typing, "Sequence", None)[T], # pyupgrade workaround
363363
pytest.param(list[T], marks=skip_39),
364364
pytest.param(Sequence[T], marks=skip_39),

hypothesis-python/tests/cover/test_validation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,13 @@ def test_recursion_validates_recursive_step():
172172

173173
@fails_with(InvalidArgument)
174174
@given(x=integers())
175-
def test_stuff_keyword(x=1):
175+
def test_stuff_keyword(x=1): # noqa: PT028
176176
pass
177177

178178

179179
@fails_with(InvalidArgument)
180180
@given(integers())
181-
def test_stuff_positional(x=1):
181+
def test_stuff_positional(x=1): # noqa: PT028
182182
pass
183183

184184

hypothesis-python/tests/nocover/test_type_lookup_forward_ref.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
99
# obtain one at https://mozilla.org/MPL/2.0/.
1010

11-
from typing import Dict as _Dict, ForwardRef, Union
11+
from typing import ForwardRef, Union
1212

1313
import pytest
1414

@@ -29,7 +29,7 @@
2929
@given(st.data())
3030
def test_mutually_recursive_types_with_typevar(data):
3131
# The previously-failing example from the issue
32-
A = _Dict[bool, "B"]
32+
A = dict[bool, "B"]
3333
B = Union[list[bool], A]
3434

3535
with pytest.raises(ResolutionFailed, match=r"Could not resolve ForwardRef\('B'\)"):

0 commit comments

Comments
 (0)