-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Stubs file for `deprecation.py`. | ||
|
||
Created using mypy's `stubgen`, types manually corrected. | ||
""" | ||
|
||
import datetime | ||
from packaging import version | ||
from typing import Callable, Optional, Union | ||
|
||
message_location: str | ||
|
||
class DeprecatedWarning(DeprecationWarning): | ||
function: str | ||
deprecated_in: Union[datetime.date, version.Version, None] | ||
removed_in: Union[datetime.date, version.Version, None] | ||
details: Union[datetime.date, version.Version, None] | ||
def __init__( | ||
self, | ||
function: str, | ||
deprecated_in: Union[datetime.date, version.Version, None], | ||
removed_in: Union[datetime.date, version.Version, None], | ||
details: str = ..., | ||
) -> None: ... | ||
|
||
class UnsupportedWarning(DeprecatedWarning): ... | ||
|
||
def deprecated( | ||
deprecated_in: Union[str, datetime.date, version.Version, None] = ..., | ||
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 commentThe 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 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: ... |
||
def fail_if_not_removed(method: Callable) -> Callable: ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Marker file for PEP 561. automeas uses inline type hints. | ||
# https://peps.python.org/pep-0561/ |
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
fordeprecated_in
,removed_in
, anddetails
. I don't thinkdetails
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