Skip to content

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

Closed

Description

@nedbat

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.

Activity

  1. changed the title [-]3.14: [/-] [+]Python 3.14: StructuralCoverageTag.__init__() takes 1 positional argument but 2 were given[/+] on Aug 5, 2024
  2. nedbat commented on Aug 5, 2024

    @nedbat
    Author

    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.

  3. hynek commented on Aug 5, 2024

    @hynek
    Contributor

    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??

  4. added
    interophow to play nicely with other packages
    on Aug 5, 2024
  5. Zac-HD commented on Aug 6, 2024

    @Zac-HD
    Member

    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

  6. Zac-HD commented on Aug 6, 2024

    @Zac-HD
    Member

    yeah, that's more like it:
    image

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

  7. hynek commented on Aug 6, 2024

    @hynek
    Contributor

    it's beautiful 🥲

  8. Zac-HD commented on Aug 6, 2024

    @Zac-HD
    Member

    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 😅

  9. hynek commented on Aug 6, 2024

    @hynek
    Contributor

    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.

  10. Zac-HD commented on Aug 6, 2024

    @Zac-HD
    Member

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

  11. hynek commented on Aug 6, 2024

    @hynek
    Contributor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    interophow to play nicely with other packages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions