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

Enum with NamedTuples which copy each other break #100361

Closed
rmtmckenzie opened this issue Dec 20, 2022 · 1 comment
Closed

Enum with NamedTuples which copy each other break #100361

rmtmckenzie opened this issue Dec 20, 2022 · 1 comment
Labels
3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@rmtmckenzie
Copy link

Bug report

I'm using a 3rd-party library as part of my CI process, and since github updated their mac image to include python 3.11.1 it is breaking. It worked fine in 3.11.0.

The 3rd-party tool is in pip; codemagic-cli-tools. When importing, it fails when declaring an enum. This can be reproduced by running from codemagic.tools import Keychain after installing version 0.36.4.

As near as I can tell, a class inheriting NamedTuple is being interpreted as a tuple when declared as part of an enum. When declared elsewhere it doesn't seem to exhibit this behaviour.

I've managed to reproduce this with a much more minimal example; when you run the following:

import enum
from typing import NamedTuple

class NT(NamedTuple):
  s: str

nt0 = NT(s="s0")
nt0._replace(s="other") # this is valid

class E(enum.Enum):
  nt1 = NT(s="s1")
  nt2 = nt1._replace(s="s2")

it fails with the error AttributeError: 'tuple' object has no attribute '_replace' in python 3.11.1 but not python 3.11.0.

If it this is in fact just incorrect python, fair enough - I'll open a bug against the codemagic-cli-tools library, but this does seem like unexpected behaviour to me.

Your environment

Python 3.11.1; I reproduced this in the docker image python:3.11.1. In the docker image python:3.11.0 the code above produces no errors.

  • CPython versions tested on: 3.11.1, 3.11.0
  • Operating system and architecture: macos x64, but run in docker
@rmtmckenzie rmtmckenzie added the type-bug An unexpected behavior, bug, or error label Dec 20, 2022
@ronaldoussoren ronaldoussoren added the stdlib Python modules in the Lib dir label Dec 20, 2022
@AlexWaygood
Copy link
Member

AlexWaygood commented Dec 20, 2022

Duplicate of #100098; it'll be fixed in 3.11.2; see #100098 for workarounds on 3.11.1

(Cc. @ethanfurman for enum stuff)

@AlexWaygood AlexWaygood closed this as not planned Won't fix, can't repro, duplicate, stale Dec 20, 2022
@AlexWaygood AlexWaygood added the 3.11 only security fixes label Dec 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants