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

Preserve type hints for wrapped functions #31

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

kadambishreyas
Copy link

@kadambishreyas kadambishreyas commented Jan 8, 2025

Makes use of typing.ParamSpec and typing.TypeVar to parametrize input/output types for decorated functions, allowing us to preserve the types of decorated functions.
We accomplish this on once_per_class and once_per_instance by making the classes themselves generic.

Since we require typing.ParamSpec which was introduced in python3.10, this PR also drops support for python3.8 and python3.9 in favour of remaining without dependencies.

Copy link
Collaborator

@mattalbr mattalbr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a unit test that failed before this PR and passes after?

.github/workflows/annotate_pr.yml Show resolved Hide resolved
once/__init__.py Show resolved Hide resolved
Copy link
Member

@aebrahim aebrahim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also update line 29 in pyproject.toml to requires-python = ">=3.8"!

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

Successfully merging this pull request may close these issues.

3 participants