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

Python 3.14: StructuralCoverageTag.__init__() takes 1 positional argument but 2 were given #4067

Closed
nedbat opened this issue Aug 5, 2024 · 9 comments · Fixed by #4069
Closed
Labels
interop how to play nicely with other packages

Comments

@nedbat
Copy link

nedbat commented Aug 5, 2024

The coverage.py nightly Python test runs started failing on Python 3.14:

      def structural_coverage(label: int) -> StructuralCoverageTag:
          try:
              return STRUCTURAL_COVERAGE_CACHE[label]
          except KeyError:
  >           return STRUCTURAL_COVERAGE_CACHE.setdefault(label, StructuralCoverageTag(label))
  E           TypeError: StructuralCoverageTag.__init__() takes 1 positional argument but 2 were given

The other Python versions are fine.

@nedbat nedbat changed the title 3.14: Python 3.14: StructuralCoverageTag.__init__() takes 1 positional argument but 2 were given Aug 5, 2024
@nedbat
Copy link
Author

nedbat commented Aug 5, 2024

Note: the deadsnakes nightly 3.14 that I've been using had been broken for a few weeks, so if this is a bug in 3.14, it could have been introduced since July 11th.

@hynek
Copy link
Contributor

hynek commented Aug 5, 2024

The breakage seems to be related to attrs 24.1.0 release.

Based on python-attrs/attrs#1326 (comment) I would guess that removing the dataclass_transform should fix it??

@Zac-HD Zac-HD added the interop how to play nicely with other packages label Aug 5, 2024
@Zac-HD
Copy link
Member

Zac-HD commented Aug 6, 2024

Thanks to both of you for the report and suggestions! I'm looking into this now and should have a fix out soon.

I'm somewhat surprised that this hasn't failed in our CI yet - we're running 3.14-dev, which pyenv is currently building from cpython main. no, this is obvious, we're currently pinned to the prior version of attrs.

I also don't see how our noop decorator could have some runtime effect:

if TYPE_CHECKING:
from typing import TypeAlias
from typing_extensions import dataclass_transform
from hypothesis.strategies import SearchStrategy
from hypothesis.strategies._internal.strategies import Ex
else:
TypeAlias = object
def dataclass_transform():
def wrapper(tp):
return tp
return wrapper

@Zac-HD
Copy link
Member

Zac-HD commented Aug 6, 2024

yeah, that's more like it:
image

(ok, with a repro in hand it's time to fix this!)

@hynek
Copy link
Contributor

hynek commented Aug 6, 2024

it's beautiful 🥲

@Zac-HD
Copy link
Member

Zac-HD commented Aug 6, 2024

cd8a71e seems to have fixed it, so my best guess is that it's (probably something in combination with) auto_attribs=True and you might be able to repro from that?

It's after midnight here though, so I'm just going to get the fix released and then go to bed 😅

@hynek
Copy link
Contributor

hynek commented Aug 6, 2024

Yes, I've finally managed to compile Python 3.14 on my Mac and apparently attrs can't find annotation-only fields on 3.14 anymore. You don't have to do anything, I've got a lead, I just want to understand better what's happening.

@Zac-HD
Copy link
Member

Zac-HD commented Aug 6, 2024

Ah, there's some other updates I wanted anyway in that PR, so might as well ship it 🙂

@hynek
Copy link
Contributor

hynek commented Aug 6, 2024

24.2.0 is out now, so you should be able to replace the whole thing with a single @attr.frozen or even @attrs.frozen since you depend on 22+ anyways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interop how to play nicely with other packages
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants