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

PEP 563 compatiblity #35

Open
bswck opened this issue Apr 5, 2024 · 6 comments
Open

PEP 563 compatiblity #35

bswck opened this issue Apr 5, 2024 · 6 comments

Comments

@bswck
Copy link

bswck commented Apr 5, 2024

Current string-check argument parsing is pretty naive and doesn't work for postponed annotations.
https://peps.python.org/pep-0563/

@bswck
Copy link
Author

bswck commented Apr 5, 2024

Example:

Having

# foo.py
from autocommand import autocommand

@autocommand(__name__)
def main(arg: int):
    pass

the python -m foo m command correctly reports an error:

usage: foo.py [-h] arg
foo.py: error: argument arg: invalid int value: 'm'

However, adding from __future__ import annotations on top of the module breaks this and skips validation:

Having

# foo-ann.py
from __future__ import annotations
from autocommand import autocommand

@autocommand(__name__)
def main(arg: int):
    pass

the python -m foo-ann m command works just fine.

@bswck
Copy link
Author

bswck commented Apr 5, 2024

Note

It was a known issue:

If you provide an annotation that is somehow both a string and a callable,
the behavior is undefined.

@bswck
Copy link
Author

bswck commented Apr 5, 2024

Related to #30.

@Lucretiel
Copy link
Owner

I'm confused by that PEP; this is just a major breaking change being shipped to a future minor release of Python?

@Lucretiel
Copy link
Owner

PEP 563 appears to have been superseded, due to backwards compatibility issues, so I'm closing this for now. Feel free to re-open if PEP is restored.

@Lucretiel Lucretiel closed this as not planned Won't fix, can't repro, duplicate, stale Apr 11, 2024
@bswck
Copy link
Author

bswck commented Apr 11, 2024

PEP 563 appears to have been superseded, due to backwards compatibility issues, so I'm closing this for now. Feel free to re-open if PEP is restored.

Strong -1 on this one. It indeed has been superseded by PEP 649, but PEP 649 is to come in Python 3.13 that hasn't yet even been released. A correct conclusion would be that PEP 563 would no longer be supported by October 2028. Until 2028, please consider supporting PEP 563, because

@Lucretiel, could you please reopen? I'm not able to do it myself.

@Lucretiel Lucretiel reopened this Apr 11, 2024
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