Closed HiromuHota closed 4 years ago
I just realized that not all methods have type hints as I expected.
For example, RegexMatchSpan
have type hints only at docstring.
class _Matcher(object):
def __init__(self, *children, **opts): # type: ignore
class _RegexMatch(_Matcher):
"""
Base regex class. Does not specify specific semantics of *what* is being
matched yet.
"""
def init(self) -> None:
class RegexMatchSpan(_RegexMatch):
"""Matches regex pattern on **full concatenated span**.
:param rgx: The RegEx pattern to use.
:type rgx: str
:param ignore_case: Whether or not to ignore case in the RegEx. Default
True.
:type ignore_case: bool
:param search: If True, *search* the regex pattern through the concatenated span.
If False, try to *match* the regex patten only at its beginning. Default False.
:type search: bool
:param full_match: If True, wrap the provided rgx with ``(<rgx>)$``.
Default True.
:type full_match: bool
:param longest_match_only: If True, only return the longest match. Default True.
Will be overridden by the parent matcher like :class:`Union` when it is wrapped
by :class:`Union`, :class:`Intersect`, or :class:`Inverse`.
:type longest_match_only: bool
"""
As of faae9c2cbc56ee4775729f0cc2730b7eec71b869, the numbers of ":type" and ":rtype" in src/ are like below:
$ grep -r ":type" src/ | wc -l
176
$ grep -r ":rtype" src/ | wc -l
106
Can we add a todo to make sure all methods have type hint?
Already exists here: https://github.com/HazyResearch/fonduer/issues/66
Awesome!
Is your feature request related to a problem? Please describe.
See https://github.com/HazyResearch/fonduer/pull/421#issuecomment-631587136.
Describe the solution you'd like
Remove redundant ":type" and ":rtype" information from the docstring
Describe alternatives you've considered
N/A.
Additional context
Now Fonduer has type hints in the method definition, which makes ":type" and ":rtype" in docstring redundant.