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
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
Change by Zac Hatfield-Dodds :
--
nosy: +brett.cannon, jaraco
___
Python tracker
<https://bugs.python.org/issue46026>
___
___
Python-bugs-list mailing list
Unsub
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Zac Hatfield-Dodds added the comment:
Unfortunately I'm overcommitted for the next few weeks-months :-/
--
___
Python tracker
<https://bugs.python.org/issue42
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
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
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
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
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
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
Change by Zac Hatfield-Dodds :
--
pull_requests: +17341
pull_request: https://github.com/python/cpython/pull/17934
___
Python tracker
<https://bugs.python.org/issue21
Change by Zac Hatfield-Dodds :
--
pull_requests: +17339
pull_request: https://github.com/python/cpython/pull/17934
___
Python tracker
<https://bugs.python.org/issue12
Change by Zac Hatfield-Dodds :
--
pull_requests: +17340
pull_request: https://github.com/python/cpython/pull/17934
___
Python tracker
<https://bugs.python.org/issue15
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
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
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
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
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
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
34 matches
Mail list logo