-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pluggable system for producing types from docstrings
- Loading branch information
Showing
4 changed files
with
124 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from typing import Dict, Optional, Callable, Tuple | ||
from mypy.errors import Errors | ||
|
||
Options = Dict[str, str] | ||
options = {} # type: Dict[str, Options] | ||
|
||
# The docstring_parser hook is called for each unannotated function that has a | ||
# docstring. The callable should accept three arguments: | ||
# - the docstring to be parsed | ||
# - a dictionary of options (parsed from the [docstring_parser] section of mypy | ||
# config file) | ||
# - an Errors object for reporting errors, warnings, and info. | ||
# | ||
# The function should return a map from argument name to 2-tuple. The latter should contain: | ||
# - a PEP484-compatible string. The function's return type, if specified, is stored | ||
# in the mapping with the special key 'return'. Other than 'return', each key of | ||
# the mapping must be one of the arguments of the documented function; otherwise, | ||
# an error will be raised. | ||
# - a line number offset, relative to the start of the docstring, used to | ||
# improve errors if the associated type string is invalid. | ||
# | ||
docstring_parser = None # type: Callable[[str, Options, Errors], Optional[Dict[str, Tuple[str, int]]]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters