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

Ghostwriter error on attrs class #3050

Closed
gmacon opened this issue Aug 4, 2021 · 1 comment · Fixed by #3051
Closed

Ghostwriter error on attrs class #3050

gmacon opened this issue Aug 4, 2021 · 1 comment · Fixed by #3051
Labels
bug something is clearly wrong here

Comments

@gmacon
Copy link
Contributor

gmacon commented Aug 4, 2021

While playing around with the ghostwriter today, I got an exception like this one running it against some internal code:

Traceback (most recent call last):
  File "/tmp/repro/venv/bin/hypothesis", line 8, in <module>
    sys.exit(main())
  File "/tmp/repro/venv/lib/python3.9/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/tmp/repro/venv/lib/python3.9/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/tmp/repro/venv/lib/python3.9/site-packages/click/core.py", line 1668, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/tmp/repro/venv/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/tmp/repro/venv/lib/python3.9/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/tmp/repro/venv/lib/python3.9/site-packages/hypothesis/extra/cli.py", line 242, in write
    code = getattr(ghostwriter, writer)(*func, except_=except_ or (), style=style)
  File "/tmp/repro/venv/lib/python3.9/site-packages/hypothesis/extra/ghostwriter.py", line 882, in magic
    make_(
  File "/tmp/repro/venv/lib/python3.9/site-packages/hypothesis/extra/ghostwriter.py", line 802, in make_
    imp, body = how(*args, **kwargs, except_=except_, style=style)
  File "/tmp/repro/venv/lib/python3.9/site-packages/hypothesis/extra/ghostwriter.py", line 626, in _make_test_body
    given_strategies = given_strategies or _get_strategies(
  File "/tmp/repro/venv/lib/python3.9/site-packages/hypothesis/extra/ghostwriter.py", line 409, in _get_strategies
    if strat.args:
AttributeError: 'MappedSearchStrategy' object has no attribute 'args'

I reduced the input to trigger this exception down to

import attr

@attr.s()
class Foo:
    foo: str = attr.ib()

I saw this with cPython 3.9.6, attrs 21.2.0, and hypothesis master branch at hypothesis-python-6.14.5-5-g9d4da6c2f.

@Zac-HD Zac-HD added the bug something is clearly wrong here label Aug 4, 2021
@Zac-HD
Copy link
Member

Zac-HD commented Aug 7, 2021

Thanks - with traceback, clean reproducer, and versions this was a very easy bug to fix 😍

halstead pushed a commit to openembedded/openembedded-core that referenced this issue Aug 19, 2021
6.14.8 - 2021-08-16
This patch ensures that registering a strategy for a subclass of a
parametrised generic type such as class Lines(Sequence[str]): will not
“leak” into unrelated strategies such as st.from_type(Sequence[int])
(issue #2951). Unfortunately this fix requires PEP 560, meaning Python
3.7 or later.

6.14.7 - 2021-08-14
This patch fixes issue #3050, where attrs classes could cause an internal
error in the ghostwriter.

6.14.6 - 2021-08-07
This patch improves the error message for issue #3016, where PEP 585 builtin
generics with self-referential forward-reference strings cannot be resolved
to a strategy by from_type().

References:
HypothesisWorks/hypothesis#2951
https://www.python.org/dev/peps/pep-0560
HypothesisWorks/hypothesis#3050
https://www.python.org/dev/peps/pep-0585

Signed-off-by: Tim Orling <timothy.t.orling@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
stefan-hartmann-lgs pushed a commit to hexagon-geo-surv/poky that referenced this issue Aug 20, 2021
6.14.8 - 2021-08-16
This patch ensures that registering a strategy for a subclass of a
parametrised generic type such as class Lines(Sequence[str]): will not
“leak” into unrelated strategies such as st.from_type(Sequence[int])
(issue #2951). Unfortunately this fix requires PEP 560, meaning Python
3.7 or later.

6.14.7 - 2021-08-14
This patch fixes issue #3050, where attrs classes could cause an internal
error in the ghostwriter.

6.14.6 - 2021-08-07
This patch improves the error message for issue #3016, where PEP 585 builtin
generics with self-referential forward-reference strings cannot be resolved
to a strategy by from_type().

References:
HypothesisWorks/hypothesis#2951
https://www.python.org/dev/peps/pep-0560
HypothesisWorks/hypothesis#3050
https://www.python.org/dev/peps/pep-0585

(From OE-Core rev: 9da4590754a2d3421ea621c28ec4e6efe058b7b4)

Signed-off-by: Tim Orling <timothy.t.orling@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to openembedded/openembedded-core that referenced this issue Aug 20, 2021
6.14.8 - 2021-08-16
This patch ensures that registering a strategy for a subclass of a
parametrised generic type such as class Lines(Sequence[str]): will not
“leak” into unrelated strategies such as st.from_type(Sequence[int])
(issue #2951). Unfortunately this fix requires PEP 560, meaning Python
3.7 or later.

6.14.7 - 2021-08-14
This patch fixes issue #3050, where attrs classes could cause an internal
error in the ghostwriter.

6.14.6 - 2021-08-07
This patch improves the error message for issue #3016, where PEP 585 builtin
generics with self-referential forward-reference strings cannot be resolved
to a strategy by from_type().

References:
HypothesisWorks/hypothesis#2951
https://www.python.org/dev/peps/pep-0560
HypothesisWorks/hypothesis#3050
https://www.python.org/dev/peps/pep-0585

Signed-off-by: Tim Orling <timothy.t.orling@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
seambot pushed a commit to seamapi/poky that referenced this issue Aug 20, 2021
6.14.8 - 2021-08-16
This patch ensures that registering a strategy for a subclass of a
parametrised generic type such as class Lines(Sequence[str]): will not
“leak” into unrelated strategies such as st.from_type(Sequence[int])
(issue #2951). Unfortunately this fix requires PEP 560, meaning Python
3.7 or later.

6.14.7 - 2021-08-14
This patch fixes issue #3050, where attrs classes could cause an internal
error in the ghostwriter.

6.14.6 - 2021-08-07
This patch improves the error message for issue #3016, where PEP 585 builtin
generics with self-referential forward-reference strings cannot be resolved
to a strategy by from_type().

References:
HypothesisWorks/hypothesis#2951
https://www.python.org/dev/peps/pep-0560
HypothesisWorks/hypothesis#3050
https://www.python.org/dev/peps/pep-0585

(From OE-Core rev: 1f2276c6d0312854caacebe1c83dee57474f1bb2)

Signed-off-by: Tim Orling <timothy.t.orling@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
daregit pushed a commit to daregit/yocto-combined that referenced this issue May 22, 2024
6.14.8 - 2021-08-16
This patch ensures that registering a strategy for a subclass of a
parametrised generic type such as class Lines(Sequence[str]): will not
“leak” into unrelated strategies such as st.from_type(Sequence[int])
(issue #2951). Unfortunately this fix requires PEP 560, meaning Python
3.7 or later.

6.14.7 - 2021-08-14
This patch fixes issue #3050, where attrs classes could cause an internal
error in the ghostwriter.

6.14.6 - 2021-08-07
This patch improves the error message for issue #3016, where PEP 585 builtin
generics with self-referential forward-reference strings cannot be resolved
to a strategy by from_type().

References:
HypothesisWorks/hypothesis#2951
https://www.python.org/dev/peps/pep-0560
HypothesisWorks/hypothesis#3050
https://www.python.org/dev/peps/pep-0585

(From OE-Core rev: 1f2276c6d0312854caacebe1c83dee57474f1bb2)

Signed-off-by: Tim Orling <timothy.t.orling@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
daregit pushed a commit to daregit/yocto-combined that referenced this issue May 22, 2024
6.14.8 - 2021-08-16
This patch ensures that registering a strategy for a subclass of a
parametrised generic type such as class Lines(Sequence[str]): will not
“leak” into unrelated strategies such as st.from_type(Sequence[int])
(issue #2951). Unfortunately this fix requires PEP 560, meaning Python
3.7 or later.

6.14.7 - 2021-08-14
This patch fixes issue #3050, where attrs classes could cause an internal
error in the ghostwriter.

6.14.6 - 2021-08-07
This patch improves the error message for issue #3016, where PEP 585 builtin
generics with self-referential forward-reference strings cannot be resolved
to a strategy by from_type().

References:
HypothesisWorks/hypothesis#2951
https://www.python.org/dev/peps/pep-0560
HypothesisWorks/hypothesis#3050
https://www.python.org/dev/peps/pep-0585

(From OE-Core rev: 1f2276c6d0312854caacebe1c83dee57474f1bb2)

Signed-off-by: Tim Orling <timothy.t.orling@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something is clearly wrong here
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants