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

Add @typing.override to functions #1310

Open
kevinjqliu opened this issue Nov 10, 2024 · 2 comments · May be fixed by #1312
Open

Add @typing.override to functions #1310

kevinjqliu opened this issue Nov 10, 2024 · 2 comments · May be fixed by #1312
Labels
good first issue Good for newcomers

Comments

@kevinjqliu
Copy link
Contributor

Feature Request / Improvement

For example, Catalog functions and FileIO functions

Only for Python 3.12 but that's ok since we run 3.12 in CI
https://rednafi.com/python/typing_override/

@kevinjqliu kevinjqliu added the good first issue Good for newcomers label Nov 10, 2024
@cosmastech
Copy link
Contributor

cosmastech commented Nov 10, 2024

Would you recommend something like this:

from typing import TYPE_CHECKING

if TYPE_CHECKING and sys.version_info >= (3, 12):
    from typing import override
else:
    # Define a no-op decorator when TYPE_CHECKING is False
    def override(func):
        return func

If so, would you recommend putting this in some kind of utility .py file? Seems like it would get used an awful lot across the codebase

@kevinjqliu
Copy link
Contributor Author

@cosmastech I dont think we need to do the override. For Python versions less than 3.12, I think this will just be a no-op
https://docs.python.org/3/library/typing.html#typing.override

@cosmastech cosmastech linked a pull request Nov 11, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants