[issue47074] Convenient `simplefilter()` in `warnings.catch_warnings()`

2022-03-20 Thread Zac Hatfield-Dodds
New submission from Zac Hatfield-Dodds : Many pytest users would like a concise way to either suppress warnings, or convert them to errors [1]. The current best approach is: with warnings.catch_warnings(): warnings.simplefilter("ignore") # or "error" b

[issue46026] importlib.resources.read_text() raises FileNotFound

2021-12-09 Thread Zac Hatfield-Dodds
Zac Hatfield-Dodds added the comment: This may have appeared in the wild, via the backport, in https://github.com/Nuitka/Nuitka/issues/1274 and https://github.com/Nuitka/Nuitka/commit/ffe861cfe972c6bf19f9eea1ff95e35d0e4240b4 -- ___ Python tracker

[issue46026] importlib.resources.read_text() raises FileNotFound

2021-12-09 Thread Zac Hatfield-Dodds
Change by Zac Hatfield-Dodds : -- nosy: +brett.cannon, jaraco ___ Python tracker <https://bugs.python.org/issue46026> ___ ___ Python-bugs-list mailing list Unsub

[issue46026] importlib.resources.read_text() raises FileNotFound

2021-12-09 Thread Zac Hatfield-Dodds
New submission from Zac Hatfield-Dodds : Testing Hypothesis with Python 3.11.0a3, I've triggered a frustrating regression in importlib.resources: # Both work in Python 3.9 and 3.10, but both fail in 3.11.0a3 from importlib.resources import files, read_text read_text("hypothesis.v

[issue42109] Use hypothesis for testing the standard library, falling back to stubs

2021-11-11 Thread Zac Hatfield-Dodds
Zac Hatfield-Dodds added the comment: I've recently had [1] reported, which makes https://bugs.python.org/issue45738 the *third* parser bug [2] that Hypothesmith caught after release, and the second in a stable version - so I'll be maintaining a workaround for some time. I remain happy

[issue45738] 3.11 exec raises SystemError instead of SyntaxError on char after line continuation

2021-11-11 Thread Zac Hatfield-Dodds
Zac Hatfield-Dodds added the comment: It looks like this also affects Python 3.9.8, which makes me very suspicious of https://bugs.python.org/issue45494 as the probable cause. See https://github.com/Zac-HD/hypothesmith/issues/16 and https://github.com/psf/black/pull/2592#issuecomment

[issue45607] Make it possible to enrich an exception's error message

2021-10-25 Thread Zac Hatfield-Dodds
Zac Hatfield-Dodds added the comment: This code shows my current best workaround based on a wrapper exception, with the traceback below annotating the additional details that I'd prefer to omit for clarity: $ python example.py Traceback (most recent call last): File "example.py&quo

[issue44246] 3.10 beta 1: breaking change in importlib.metadata entry points

2021-05-29 Thread Zac Hatfield-Dodds
Zac Hatfield-Dodds added the comment: Just chiming in with a plea to slow down the rate of changes to importlib.metadata - I understand that you want to tidy up the API, but even deprecations cause substantial work downstream. Would it really be so bad to support the older APIs until

[issue42109] Use hypothesis for testing the standard library, falling back to stubs

2021-05-19 Thread Zac Hatfield-Dodds
Zac Hatfield-Dodds added the comment: > Okay, well, I'm trying to understand minithesis.py, but I am despairing. The > shrinking code (really everything in class TestingState) is too much to grok. > ... I suppose I have to read the paper at > https://drmaciver.github.io/papers/r

[issue42109] Use hypothesis for testing the standard library, falling back to stubs

2021-05-13 Thread Zac Hatfield-Dodds
Zac Hatfield-Dodds added the comment: (I think structuring this as a high-level explanation is clearer than point-by-point replies - it covers most of them, but the logic is hopefully easier to follow) The core idea of Hypothesis is that making random choices is equivalent to parsing

[issue43006] Changed behaviour of inspect.signature() in Python 3.10

2021-05-03 Thread Zac Hatfield-Dodds
Zac Hatfield-Dodds added the comment: I think that with PEP-563 reverted, this issue has been fixed. If we have a similar problem from e.g. PEP-649, I'll open another ticket then! -- resolution: -> fixed stage: -> resolved status: open -&g

[issue43006] Changed behaviour of inspect.signature() in Python 3.10

2021-01-23 Thread Zac Hatfield-Dodds
Zac Hatfield-Dodds added the comment: And I promise this is the last one: import inspect import typing def f(): A = typing.TypeVar("A") def same_type_args(a: A, b: A): assert type(a) == type(b) print(inspect.signature(same

[issue43006] Changed behaviour of inspect.signature() in Python 3.10

2021-01-23 Thread Zac Hatfield-Dodds
Zac Hatfield-Dodds added the comment: Aaaand it looks like another problem I'm having is also related: import inspect class T(typing.TypedDict): a: int print(inspect.signature(T)) was `(*args, **kwargs)` and now raises `ValueError: no signature found for builtin type

[issue43006] Changed behaviour of inspect.signature() in Python 3.10

2021-01-23 Thread Zac Hatfield-Dodds
Zac Hatfield-Dodds added the comment: A closely related problem, also via https://github.com/HypothesisWorks/hypothesis/issues/2767 import inspect def f(x) -> None: pass annotations = inspect.getfullargspec(f).annotations assert annotations == {"retur

[issue43006] Changed behaviour of inspect.signature() in Python 3.10

2021-01-22 Thread Zac Hatfield-Dodds
New submission from Zac Hatfield-Dodds : Consider the following snippet, which passes on Python 3.9 and earlier: import inspect def f(x: int = None): pass print(inspect.signature(constructor)) assert inspect.signature(constructor).parameters["a"].annotat

[issue42195] Inconsistent __args__ between typing.Callable and collections.abc.Callable

2020-11-15 Thread Zac Hatfield-Dodds
Zac Hatfield-Dodds added the comment: > @Hatfield-Dodds, if we changed typing.Callable to return ((int, int), str) > but collections.abc.Callable continued to return ([int, int], str), would > that suffice for your purposes? For performance reasons I'd prefer that the ret

[issue42218] SystemError in compile builtin function

2020-10-31 Thread Zac Hatfield-Dodds
Zac Hatfield-Dodds added the comment: Wow! Thanks and congrats on the super-fast fix :-) FYI Paul Ganssle has recently [1] started to work on adding property-based tests to CPython CI [2]. Once Paul gets the stubs and first set of tests working, I'll start moving the others over from my

[issue42218] SystemError in compile builtin function

2020-10-31 Thread Zac Hatfield-Dodds
New submission from Zac Hatfield-Dodds : In Python 3.9.0, running compile('A.\u018a\\ ', '', 'single') raises SystemError: returned a result with an error set This is obviously invalid syntax, but it would still be nice to raise SyntaxError for that and the SystemError may

[issue42195] Inconsistent __args__ between typing.Callable and collections.abc.Callable

2020-10-29 Thread Zac Hatfield-Dodds
Zac Hatfield-Dodds added the comment: Unfortunately I'm overcommitted for the next few weeks-months :-/ -- ___ Python tracker <https://bugs.python.org/issue42

[issue42195] Inconsistent __args__ between typing.Callable and collections.abc.Callable

2020-10-29 Thread Zac Hatfield-Dodds
New submission from Zac Hatfield-Dodds : The two ways of getting a parametrised Callable have inconsistent __args__: >>> import collections.abc, typing >>> typing.Callable[[int, int], int].__args__ (int, int, int) >>> collections.abc.Callable[[int, in

[issue38953] Untokenize and retokenize does not round-trip

2020-10-23 Thread Zac Hatfield-Dodds
Zac Hatfield-Dodds added the comment: Thanks for your comments Terry - I'm delighted that it's useful. It's been a while since I wrote that, and entirely possible that it's just a typo. Hypothesis does indeed support unittest, including for multiple-failure reporting and so on. You can

[issue39046] collections.abc.Reversible should not be a subclass of Hashable

2020-10-22 Thread Zac Hatfield-Dodds
Zac Hatfield-Dodds added the comment: I'm closing this as not-a-bug. The way protocols just check methods does make sense (thanks for your comment Guido!), and a later refactoring of the code that prompted this issue (to deal only in concrete classes) dissolved the problem

[issue40668] Catastrophic loss of precision in colorsys module

2020-05-18 Thread Zac Hatfield-Dodds
New submission from Zac Hatfield-Dodds : As part of the Mentored Sprints at PyCon US, Marielle wrote some property-based tests [1] for the colorsys module [2], which found two bugs. Taking a YIQ color, converting to RGB, and back to YIQ can result in the Y coordinate varying by more 0.1

[issue40661] The new parser segfaults when parsing invalid input

2020-05-18 Thread Zac Hatfield-Dodds
Zac Hatfield-Dodds added the comment: I know what else it might find either, but I still think it's worth running property-based tests in CI to find out! The demo I wrote for my language summit talk doesn't have any parser tests, but still would have caught this bug in the pull request

[issue40661] The new parser segfaults when parsing invalid input

2020-05-17 Thread Zac Hatfield-Dodds
Zac Hatfield-Dodds added the comment: I understand from Paul Ganssle that this bug was found using Hypothesmith in my stdlib property tests (reported at https://github.com/Zac-HD/stdlib-property-tests/issues/14). As discussed in https://github.com/we-like-parsers/cpython/issues/91

[issue21444] __len__ can't return big numbers

2020-01-10 Thread Zac Hatfield-Dodds
Change by Zac Hatfield-Dodds : -- pull_requests: +17341 pull_request: https://github.com/python/cpython/pull/17934 ___ Python tracker <https://bugs.python.org/issue21

[issue12159] Integer Overflow in __len__

2020-01-10 Thread Zac Hatfield-Dodds
Change by Zac Hatfield-Dodds : -- pull_requests: +17339 pull_request: https://github.com/python/cpython/pull/17934 ___ Python tracker <https://bugs.python.org/issue12

[issue15718] Possible OverflowError in __len__ method undocumented (when called via len() function)

2020-01-10 Thread Zac Hatfield-Dodds
Change by Zac Hatfield-Dodds : -- pull_requests: +17340 pull_request: https://github.com/python/cpython/pull/17934 ___ Python tracker <https://bugs.python.org/issue15

[issue39227] OverflowError in len(range(2**63))

2020-01-05 Thread Zac Hatfield-Dodds
New submission from Zac Hatfield-Dodds : The value for `len` internally passes through an `ssize_t`, which means that it raises OverflowError for (very) large collections. This is admittedly only possible with collections such as `range` that do not store all their elements in memory

[issue39046] collections.abc.Reversible should not be a subclass of Hashable

2019-12-14 Thread Zac Hatfield-Dodds
New submission from Zac Hatfield-Dodds : >>> from collections.abc import Hashable, Reversible >>> assert issubclass(Reversible, Hashable) However, this is trivially wrong - lists are Reversible but not Hashable, and there is no reason to thing that reversible objects shou

[issue38953] Untokenize and retokenize does not round-trip

2019-12-02 Thread Zac Hatfield-Dodds
New submission from Zac Hatfield-Dodds : I've been working on a tool called Hypothesmith - https://github.com/Zac-HD/hypothesmith - to generate arbitrary Python source code, inspired by CSmith's success in finding C compiler bugs. It's based on the grammar but ultimately only generates

[issue38834] TypedDict: no way to tell which (if any) keys are optional at runtime

2019-11-17 Thread Zac Hatfield-Dodds
Change by Zac Hatfield-Dodds : -- keywords: +patch pull_requests: +16717 stage: -> patch review pull_request: https://github.com/python/cpython/pull/17214 ___ Python tracker <https://bugs.python.org/issu

[issue38834] TypedDict: no way to tell which (if any) keys are optional at runtime

2019-11-17 Thread Zac Hatfield-Dodds
New submission from Zac Hatfield-Dodds : Consider the following cases: ```python class A(typing.TypedDict): a: int # a is required class B(A, total=False): b: bool # a is required, b is optional class C(B): c: str # a is required, b is optional, c is required again ``` PEP

[issue26967] argparse: allow_abbrev=False stops -vv from working

2019-06-22 Thread Zac Hatfield-Dodds
Change by Zac Hatfield-Dodds : -- keywords: +patch pull_requests: +14140 stage: needs patch -> patch review pull_request: https://github.com/python/cpython/pull/14316 ___ Python tracker <https://bugs.python.org/issu