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

Unable to use newer syntax of typing #280

Open
fer-git opened this issue Mar 30, 2023 · 1 comment
Open

Unable to use newer syntax of typing #280

fer-git opened this issue Mar 30, 2023 · 1 comment

Comments

@fer-git
Copy link

fer-git commented Mar 30, 2023

Describe the bug
I would like to use generic types such as list[int] instead of from typing import List; List[int].

I do know that the example in the documentation explicitly show that I need to import List from typing, but ever since python 3.9, it is preferred to directly use list as type annotation.

To Reproduce
Create file simple.py

from spock import SpockBuilder, spock

@spock
class BasicConfig:
    most_fancy_parameter: list[int]

def main():
    config = SpockBuilder(BasicConfig, desc="Quick start example").generate()
    print(config)

if __name__ == "__main__":
    main()

Run the script,

python simple.py --BasicConfig.most_fancy_parameter "[128, 128]"    

I got:

spock.exceptions._SpockInstantiationError: Spock class `BasicConfig` could not be instantiated -- attrs message: isinstance() argument 2 cannot be a parameterized generic

Environment (please complete the following information):

  • OS: Mac 10.13
  • Python version: 3.10
  • Spock version: 3.0.2
@ncilfone
Copy link
Contributor

Noted. Will see what it takes to support the basic non typing lib types.

I'm assuming the following basic types:

  • int
  • float
  • str
  • list
  • tuple
  • dict

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