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

Replace Python 2 type hints with real type annotations #559

Merged
merged 2 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,9 @@ In addition, the project follows a convention of:
- Maximum line length: 80 characters
- Indentation: 2 spaces (4 for line continuation)
- PascalCase for function and method names.
- No type hints, as described in [PEP 484], to maintain compatibility with
Python versions < 3.5.
- Single quotes around strings, three double quotes around docstrings.

[Google Python Style Guide]: http://google.github.io/styleguide/pyguide.html
[PEP 484]: https://www.python.org/dev/peps/pep-0484

## Testing

Expand Down
7 changes: 3 additions & 4 deletions fire/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
command line arguments to client code.
"""

from typing import Any, Dict
import inspect

FIRE_METADATA = 'FIRE_METADATA'
Expand Down Expand Up @@ -80,8 +81,7 @@ def _SetMetadata(fn, attribute, value):
setattr(fn, FIRE_METADATA, metadata)


def GetMetadata(fn):
# type: (...) -> dict
def GetMetadata(fn) -> Dict[str, Any]:
"""Gets metadata attached to the function `fn` as an attribute.

Args:
Expand All @@ -104,8 +104,7 @@ def GetMetadata(fn):
return default


def GetParseFns(fn):
# type: (...) -> dict
def GetParseFns(fn) -> Dict[str, Any]:
metadata = GetMetadata(fn)
default = {'default': None, 'positional': [], 'named': {}}
return metadata.get(FIRE_PARSE_FNS, default)
Loading