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

Invalid function name for locally defined classes #319

Closed
LukasKrocek opened this issue Nov 3, 2022 · 2 comments
Closed

Invalid function name for locally defined classes #319

LukasKrocek opened this issue Nov 3, 2022 · 2 comments

Comments

@LukasKrocek
Copy link

  • cattrs version: 22.2.0
  • Python version: 3.8

Description

def my_test():
    @frozen
    class A(Generic[T]):
        a: int
        b: T

    @frozen
    class B:
        pass
    
    cattrs.structure({"a": 1, "b": []}, A[Sequence[B]])
=> Syntax error 

generated function name is: structure_A_typing_Sequence___main___my_test_<locals>_B_
name = re.sub(r"[\[\.\] ,]", "_", name) probably needs to have <> added to make it work :)

@Tinche
Copy link
Member

Tinche commented Nov 4, 2022

Eeep. Care to put together a quick PR? :)

@Tinche
Copy link
Member

Tinche commented Jan 3, 2023

Just merged a fix for this, thanks!

@Tinche Tinche closed this as completed Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants