-
Notifications
You must be signed in to change notification settings - Fork 31
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
Feature/add_type_information #63
base: master
Are you sure you want to change the base?
Conversation
0193c91
to
f16d2d0
Compare
f16d2d0
to
b502d61
Compare
removed_in: Union[str, datetime.date, version.Version, None] = ..., | ||
current_version: Union[str, datetime.date, version.Version, None] = ..., | ||
details: str = ..., | ||
) -> Callable: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using a TypeVar for the wrapped function so that the decorator's type hints preserve the function's signature. Pylance (in VS Code) manages to display the signature without this (perhaps due to the implementation's use of @functools.wraps
?), but mypy shows Any
if I use reveal_type
on a deprecated function.
Example: https://github.com/python/typeshed/blob/main/stdlib/contextlib.pyi#L34
_F = TypeVar("_F", bound=Callable[..., Any])
def deprecated(...) -> Callable[[_F], _F]: ...
def fail_if_not_removed(method: _F) -> _F: ...
deprecated_in: Union[datetime.date, version.Version, None] | ||
removed_in: Union[datetime.date, version.Version, None] | ||
details: Union[datetime.date, version.Version, None] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The examples in the readme pass str
for deprecated_in
, removed_in
, and details
. I don't think details
is ever a date/version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the code supports datetime.date
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, removed_in
can be a date. I don't see any indication that the other two fields can be a date.
Based on the code and docstrings, it looks like:
deprecated_in
: version, str, or Noneremoved_in
: date, version, str, or Nonedetails
: str or None
resolves #56
Solution to add types to package using a stubs file
deprecation.pyi
)py.typed
marker file to indicate that package has type hintspy.typed
and__init__.py
@briancurtin