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

Topotato docstring linting #136

Open
wants to merge 3 commits into
base: topotato-base
Choose a base branch
from

Conversation

eznix86
Copy link

@eznix86 eznix86 commented Sep 29, 2023

Adding pre-commit linting allow us to have a consistent documentation for sphinx. Right now we have those various linters:

  • pydoclint (it will catch inconsistency in docstrings)
  • darg2lint2 (it will catch undocumented arguments or returns in functions - classes linting not supported yet)

Solving inconsistency and issues in docstrings will improve consistency (sphinx only) and comprehensiveness (prevent undocumented areas - in functions/classes).

…tion

Signed-off-by: Bruno Bernard <contact.brunobernard@gmail.com>
Signed-off-by: Bruno Bernard <contact.brunobernard@gmail.com>
@eznix86
Copy link
Author

eznix86 commented Sep 29, 2023

Current docstring issues to be solved

topotato/base.py
    74: DOC203: Method `_SkipTrace.get_callers` return type(s) in docstring not consistent with the return annotation. Return annotation types: ['List[inspect.FrameInfo]']; docstring return section types: ['']
    74: DOC501: Method `_SkipTrace.get_callers` has "raise" statements, but the docstring does not have a "Raises" section 
    593: DOC101: Function `topotatofunc`: Docstring contains fewer arguments than in function signature. 
    593: DOC107: Function `topotatofunc`: The option `--arg-type-hints-in-signature` is `True` but not all args in the signature have type hints 
    593: DOC103: Function `topotatofunc`: Docstring arguments are different from function arguments. (Or could be other formatting issues: https://jsh9.github.io/pydoclint/violation_codes.html#notes-on-doc103 ). Arguments in the function signature but not in the docstring: [fn: Optional[Callable], include_startup: ]. Arguments in the docstring but not in the function signature: [include_startup: bool].
    593: DOC201: Function `topotatofunc` does not have a return section in docstring 

topotato/frr/core.py
    162: DOC301: Class `FRRSetup`: __init__() should not have a docstring; please combine it with the docstring of the class 
    806: DOC109: Method `RouterFRR.require_defun`: The option `--arg-type-hints-in-docstring` is `True` but there are no type hints in the docstring arg list 
    806: DOC110: Method `RouterFRR.require_defun`: The option `--arg-type-hints-in-docstring` is `True` but not all args in the docstring arg list have type hints 
    806: DOC105: Method `RouterFRR.require_defun`: Argument names match, but type hints do not match 
    831: DOC109: Method `RouterFRR.require_logmsg`: The option `--arg-type-hints-in-docstring` is `True` but there are no type hints in the docstring arg list 
    831: DOC110: Method `RouterFRR.require_logmsg`: The option `--arg-type-hints-in-docstring` is `True` but not all args in the docstring arg list have type hints 
    831: DOC105: Method `RouterFRR.require_logmsg`: Argument names match, but type hints do not match 

topotato/jinlinja.py
    128: DOC101: Method `InlineEnv.compile_class_attr`: Docstring contains fewer arguments than in function signature. 
    128: DOC109: Method `InlineEnv.compile_class_attr`: The option `--arg-type-hints-in-docstring` is `True` but there are no type hints in the docstring arg list 
    128: DOC110: Method `InlineEnv.compile_class_attr`: The option `--arg-type-hints-in-docstring` is `True` but not all args in the docstring arg list have type hints 
    128: DOC103: Method `InlineEnv.compile_class_attr`: Docstring arguments are different from function arguments. (Or could be other formatting issues: https://jsh9.github.io/pydoclint/violation_codes.html#notes-on-doc103 ). Arguments in the function signature but not in the docstring: [attr: str, cls: Type, globals_: Optional[MutableMapping[str, Any]], template_class: Optional[Type['jinja2.Template']]]. Arguments in the docstring but not in the function signature: [attr: , cls: ].
    128: DOC201: Method `InlineEnv.compile_class_attr` does not have a return section in docstring 
    128: DOC501: Method `InlineEnv.compile_class_attr` has "raise" statements, but the docstring does not have a "Raises" section 

topotato/parse.py
    327: DOC301: Class `Topology`: __init__() should not have a docstring; please combine it with the docstring of the class 

topotato/timeline.py
    122: DOC101: Method `MiniPoller.sleep`: Docstring contains fewer arguments than in function signature. 
    122: DOC109: Method `MiniPoller.sleep`: The option `--arg-type-hints-in-docstring` is `True` but there are no type hints in the docstring arg list 
    122: DOC110: Method `MiniPoller.sleep`: The option `--arg-type-hints-in-docstring` is `True` but not all args in the docstring arg list have type hints 
    122: DOC103: Method `MiniPoller.sleep`: Docstring arguments are different from function arguments. (Or could be other formatting issues: https://jsh9.github.io/pydoclint/violation_codes.html#notes-on-doc103 ). Arguments in the function signature but not in the docstring: [duration: float, final: Union[bool, Iterable[MiniPollee]]]. Arguments in the docstring but not in the function signature: [final: ].
    150: DOC107: Method `MiniPoller.run_iter`: The option `--arg-type-hints-in-signature` is `True` but not all args in the signature have type hints 
    150: DOC109: Method `MiniPoller.run_iter`: The option `--arg-type-hints-in-docstring` is `True` but there are no type hints in the docstring arg list 
    150: DOC110: Method `MiniPoller.run_iter`: The option `--arg-type-hints-in-docstring` is `True` but not all args in the docstring arg list have type hints 
    150: DOC105: Method `MiniPoller.run_iter`: Argument names match, but type hints do not match 

topotato/utils.py
    68: DOC101: Function `get_textdiff`: Docstring contains fewer arguments than in function signature. 
    68: DOC107: Function `get_textdiff`: The option `--arg-type-hints-in-signature` is `True` but not all args in the signature have type hints 
    68: DOC109: Function `get_textdiff`: The option `--arg-type-hints-in-docstring` is `True` but there are no type hints in the docstring arg list 
    68: DOC110: Function `get_textdiff`: The option `--arg-type-hints-in-docstring` is `True` but not all args in the docstring arg list have type hints 
    68: DOC103: Function `get_textdiff`: Docstring arguments are different from function arguments. (Or could be other formatting issues: https://jsh9.github.io/pydoclint/violation_codes.html#notes-on-doc103 ). Arguments in the function signature but not in the docstring: [**opts: , text1: str, text2: str, title1: , title2: ]. Arguments in the docstring but not in the function signature: [opts: ].
    68: DOC203: Function `get_textdiff` return type(s) in docstring not consistent with the return annotation. Return annotation types: ['str']; docstring return section types: ['']
    149: DOC106: Method `JSONCompareListKeyedDict.__init__`: The option `--arg-type-hints-in-signature` is `True` but there are no argument type hints in the signature 
    149: DOC109: Method `JSONCompareListKeyedDict.__init__`: The option `--arg-type-hints-in-docstring` is `True` but there are no type hints in the docstring arg list 
    149: DOC110: Method `JSONCompareListKeyedDict.__init__`: The option `--arg-type-hints-in-docstring` is `True` but not all args in the docstring arg list have type hints 
    149: DOC103: Method `JSONCompareListKeyedDict.__init__`: Docstring arguments are different from function arguments. (Or could be other formatting issues: https://jsh9.github.io/pydoclint/violation_codes.html#notes-on-doc103 ). Arguments in the function signature but not in the docstring: [*keying: ]. Arguments in the docstring but not in the function signature: [keying: ].

darglint2................................................................Failed
- hook id: darglint2
- exit code: 1

topotato/base.py:74 -> (in get_callers) Missing exception(s) in Raises section: -r IndexError
topotato/base.py:75 -> (in get_callers) Incorrect indentation: ~<
topotato/base.py:160 -> (in from_parent) Missing parameter(s) in Docstring: - **kw
topotato/base.py:160 -> (in from_parent) Missing parameter(s) in Docstring: - *args
topotato/base.py:160 -> (in from_parent) Missing parameter(s) in Docstring: - parent
topotato/base.py:160 -> (in from_parent) Missing "Returns" in Docstring: - return
topotato/base.py:160 -> (in from_parent) Missing exception(s) in Raises section: -r TopotatoUnhandledArgs
topotato/base.py:223 -> (in make) Missing parameter(s) in Docstring: - **kwargs
topotato/base.py:223 -> (in make) Missing parameter(s) in Docstring: - *args
topotato/base.py:223 -> (in make) Missing "Returns" in Docstring: - return
topotato/base.py:223 -> (in make) Missing "Yields" in Docstring: - yield
topotato/base.py:223 -> (in make) Missing exception(s) in Raises section: -r TopotatoUnhandledArgs
topotato/base.py:272 -> (in pytest_pycollect_makeitem) Missing parameter(s) in Docstring: - collector
topotato/base.py:272 -> (in pytest_pycollect_makeitem) Missing parameter(s) in Docstring: - name
topotato/base.py:272 -> (in pytest_pycollect_makeitem) Missing parameter(s) in Docstring: - obj
topotato/base.py:272 -> (in pytest_pycollect_makeitem) Missing "Returns" in Docstring: - return
topotato/base.py:330 -> (in reportinfo) Missing "Returns" in Docstring: - return
topotato/base.py:407 -> (in repr_failure) Missing parameter(s) in Docstring: - excinfo
topotato/base.py:407 -> (in repr_failure) Missing "Returns" in Docstring: - return
topotato/base.py:407 -> (in repr_failure) Missing parameter(s) in Docstring: - style
topotato/base.py:499 -> (in _topotato_makeitem) Missing parameter(s) in Docstring: - collector
topotato/base.py:499 -> (in _topotato_makeitem) Missing parameter(s) in Docstring: - name
topotato/base.py:499 -> (in _topotato_makeitem) Missing parameter(s) in Docstring: - obj
topotato/base.py:499 -> (in _topotato_makeitem) Missing "Returns" in Docstring: - return
topotato/base.py:583 -> (in _topotato_makeitem) Missing parameter(s) in Docstring: - collector
topotato/base.py:583 -> (in _topotato_makeitem) Missing parameter(s) in Docstring: - name
topotato/base.py:583 -> (in _topotato_makeitem) Missing parameter(s) in Docstring: - obj
topotato/base.py:583 -> (in _topotato_makeitem) Missing "Returns" in Docstring: - return
topotato/base.py:593 -> (in topotatofunc) Missing "Returns" in Docstring: - return
topotato/base.py:596 -> (in topotatofunc) Excess parameter(s) in Docstring: + bool include_startup
topotato/base.py:596 -> (in topotatofunc) Missing parameter(s) in Docstring: - fn
topotato/base.py:596 -> (in topotatofunc) Missing parameter(s) in Docstring: - include_startup
topotato/base.py:596 -> (in topotatofunc) Incorrect indentation: ~<
topotato/base.py:748 -> (in collect) Missing "Yields" in Docstring: - yield

topotato/fixtures.py:26 -> (in mkfixture_pytest) Missing parameter(s) in Docstring: - **kwargs
topotato/fixtures.py:26 -> (in mkfixture_pytest) Missing parameter(s) in Docstring: - *args
topotato/fixtures.py:26 -> (in mkfixture_pytest) Missing "Returns" in Docstring: - return
topotato/fixtures.py:41 -> (in topology_fixture) Missing "Returns" in Docstring: - return

topotato/frr/core.py:162 -> (in __init__) Missing parameter(s) in Docstring: - frrpath
topotato/frr/core.py:162 -> (in __init__) Missing parameter(s) in Docstring: - result
topotato/frr/core.py:321 -> (in eval) Missing "Returns" in Docstring: - return
topotato/frr/core.py:321 -> (in eval) Missing parameter(s) in Docstring: - rtr
topotato/frr/core.py:321 -> (in eval) Missing parameter(s) in Docstring: - text
topotato/frr/core.py:332 -> (in prepare) Missing "Returns" in Docstring: - return
topotato/frr/core.py:855 -> (in eval) Missing "Returns" in Docstring: - return
topotato/frr/core.py:855 -> (in eval) Missing parameter(s) in Docstring: - rtr
topotato/frr/core.py:855 -> (in eval) Missing parameter(s) in Docstring: - text
topotato/frr/core.py:867 -> (in __init_subclass__) Missing parameter(s) in Docstring: - **kwargs
topotato/frr/core.py:867 -> (in __init_subclass__) Missing "Returns" in Docstring: - return

topotato/frr/livelog.py:206 -> (in iter_args) Missing "Yields" in Docstring: - yield
topotato/frr/livelog.py:289 -> (in wrfd) Missing "Returns" in Docstring: - return
topotato/frr/livelog.py:289 -> (in wrfd) Missing exception(s) in Raises section: -r ValueError
topotato/frr/livelog.py:318 -> (in readable) Missing "Yields" in Docstring: - yield

topotato/frr/templating.py:58 -> (in static_route_for) Missing parameter(s) in Docstring: - dst
topotato/frr/templating.py:58 -> (in static_route_for) Missing "Returns" in Docstring: - return
topotato/frr/templating.py:58 -> (in static_route_for) Missing parameter(s) in Docstring: - rtr_filter
topotato/frr/templating.py:58 -> (in static_route_for) Missing exception(s) in Raises section: -r RuntimeError

topotato/jinlinja.py:47 -> (in _reframe) Missing parameter(s) in Docstring: - filename
topotato/jinlinja.py:47 -> (in _reframe) Missing "Returns" in Docstring: - return
topotato/jinlinja.py:65 -> (in search) Missing parameter(s) in Docstring: - filename
topotato/jinlinja.py:65 -> (in search) Missing "Returns" in Docstring: - return
topotato/jinlinja.py:65 -> (in search) Missing parameter(s) in Docstring: - src
topotato/jinlinja.py:65 -> (in search) Missing parameter(s) in Docstring: - text
topotato/jinlinja.py:133 -> (in compile_class_attr) Missing "Returns" in Docstring: - return
topotato/jinlinja.py:133 -> (in compile_class_attr) Missing exception(s) in Raises section: -r RuntimeError
topotato/jinlinja.py:139 -> (in compile_class_attr) Missing parameter(s) in Docstring: - globals_
topotato/jinlinja.py:139 -> (in compile_class_attr) Missing parameter(s) in Docstring: - template_class
topotato/jinlinja.py:139 -> (in compile_class_attr) Incorrect indentation: ~<

topotato/nswrap.py:57 -> (in find_child) Missing parameter(s) in Docstring: - parent
topotato/nswrap.py:57 -> (in find_child) Missing "Returns" in Docstring: - return
topotato/nswrap.py:57 -> (in find_child) Missing exception(s) in Raises section: -r ValueError

topotato/pcapng.py:87 -> (in pack) Missing parameter(s) in Docstring: - *args
topotato/pcapng.py:87 -> (in pack) Missing "Returns" in Docstring: - return
topotato/pcapng.py:87 -> (in pack) Missing parameter(s) in Docstring: - spec
topotato/pcapng.py:191 -> (in encode) Missing parameter(s) in Docstring: - context
topotato/pcapng.py:191 -> (in encode) Missing "Returns" in Docstring: - return

topotato/potatool.py:253 -> (in do_session) Missing parameter(s) in Docstring: - name
topotato/potatool.py:277 -> (in do_router) Missing parameter(s) in Docstring: - name
topotato/potatool.py:316 -> (in do_shell) Missing parameter(s) in Docstring: - command
topotato/potatool.py:316 -> (in do_shell) Missing "Returns" in Docstring: - return
topotato/potatool.py:316 -> (in do_shell) Missing parameter(s) in Docstring: - router

topotato/timeline.py:75 -> (in readable) Missing "Yields" in Docstring: - yield
topotato/timeline.py:75 -> (in readable) Missing exception(s) in Raises section: -r NotImplementedError
topotato/timeline.py:95 -> (in serialize) Missing parameter(s) in Docstring: - context
topotato/timeline.py:95 -> (in serialize) Missing "Yields" in Docstring: - yield
topotato/timeline.py:125 -> (in sleep) Missing parameter(s) in Docstring: - duration
topotato/timeline.py:131 -> (in run_tick) Missing parameter(s) in Docstring: - timing
topotato/timeline.py:131 -> (in run_tick) Missing "Yields" in Docstring: - yield
topotato/timeline.py:151 -> (in run_iter) Missing "Yields" in Docstring: - yield
topotato/timeline.py:234 -> (in serialize) Missing parameter(s) in Docstring: - context

topotato/topobase.py:67 -> (in start_post) Missing parameter(s) in Docstring: - failed
topotato/topobase.py:67 -> (in start_post) Missing parameter(s) in Docstring: - timeline
topotato/topobase.py:122 -> (in routes) Missing parameter(s) in Docstring: - af
topotato/topobase.py:122 -> (in routes) Missing parameter(s) in Docstring: - local
topotato/topobase.py:180 -> (in make) Missing parameter(s) in Docstring: - name
topotato/topobase.py:180 -> (in make) Missing "Returns" in Docstring: - return

topotato/topofreebsd.py:26 -> (in ifname) Missing parameter(s) in Docstring: - host
topotato/topofreebsd.py:26 -> (in ifname) Missing parameter(s) in Docstring: - iface
topotato/topofreebsd.py:26 -> (in ifname) Missing "Returns" in Docstring: - return
topotato/topofreebsd.py:64 -> (in routes) Missing parameter(s) in Docstring: - af
topotato/topofreebsd.py:64 -> (in routes) Missing parameter(s) in Docstring: - local
topotato/topofreebsd.py:64 -> (in routes) Missing "Returns" in Docstring: - return
topotato/topofreebsd.py:198 -> (in link_set) Missing parameter(s) in Docstring: - iface
topotato/topofreebsd.py:198 -> (in link_set) Missing parameter(s) in Docstring: - state

topotato/topolinux.py:40 -> (in ifname) Missing parameter(s) in Docstring: - host
topotato/topolinux.py:40 -> (in ifname) Missing parameter(s) in Docstring: - iface
topotato/topolinux.py:40 -> (in ifname) Missing "Returns" in Docstring: - return
topotato/topolinux.py:132 -> (in routes) Missing parameter(s) in Docstring: - af
topotato/topolinux.py:132 -> (in routes) Missing parameter(s) in Docstring: - local
topotato/topolinux.py:132 -> (in routes) Missing "Returns" in Docstring: - return
topotato/topolinux.py:290 -> (in link_set) Missing parameter(s) in Docstring: - iface
topotato/topolinux.py:290 -> (in link_set) Missing parameter(s) in Docstring: - state

topotato/toponom.py:141 -> (in name_to_tuple) Missing parameter(s) in Docstring: - name
topotato/toponom.py:141 -> (in name_to_tuple) Missing "Returns" in Docstring: - return
topotato/toponom.py:232 -> (in iface_peer) Missing parameter(s) in Docstring: - other
topotato/toponom.py:232 -> (in iface_peer) Missing "Returns" in Docstring: - return
topotato/toponom.py:232 -> (in iface_peer) Missing parameter(s) in Docstring: - via

topotato/utils.py:31 -> (in deindent) Missing "Returns" in Docstring: - return
topotato/utils.py:31 -> (in deindent) Missing parameter(s) in Docstring: - text
topotato/utils.py:31 -> (in deindent) Missing parameter(s) in Docstring: - trim
topotato/utils.py:71 -> (in get_textdiff) Missing parameter(s) in Docstring: - text1
topotato/utils.py:71 -> (in get_textdiff) Missing parameter(s) in Docstring: - text2
topotato/utils.py:71 -> (in get_textdiff) Missing parameter(s) in Docstring: - title1
topotato/utils.py:71 -> (in get_textdiff) Missing parameter(s) in Docstring: - title2
topotato/utils.py:289 -> (in json_cmp) Missing parameter(s) in Docstring: - d1
topotato/utils.py:289 -> (in json_cmp) Missing parameter(s) in Docstring: - d2
topotato/utils.py:289 -> (in json_cmp) Missing "Returns" in Docstring: - return
topotato/utils.py:289 -> (in json_cmp) Missing exception(s) in Raises section: -r JSONCompareDirectiveWrongSide
topotato/utils.py:289 -> (in json_cmp) Missing exception(s) in Raises section: -r JSONCompareUnexpectedDirective
topotato/utils.py:593 -> (in lock) Missing "Returns" in Docstring: - return

topotato/watch.py:59 -> (in _getlockpid) Missing parameter(s) in Docstring: - filename
topotato/watch.py:59 -> (in _getlockpid) Missing "Returns" in Docstring: - return
topotato/watch.py:59 -> (in _getlockpid) Missing exception(s) in Raises section: -r subprocess.CalledProcessError
topotato/watch.py:173 -> (in session_started) Missing parameter(s) in Docstring: - inst
topotato/watch.py:182 -> (in session_stopped) Missing parameter(s) in Docstring: - inst
topotato/watch.py:234 -> (in _ino_process) Missing parameter(s) in Docstring: - event
topotato/watch.py:257 -> (in start_watch) Missing parameter(s) in Docstring: - wm
topotato/watch.py:281 -> (in _ino_process_root) Missing parameter(s) in Docstring: - event
topotato/watch.py:317 -> (in run) Missing parameter(s) in Docstring: - cmd

Signed-off-by: Bruno Bernard <contact.brunobernard@gmail.com>
@eznix86 eznix86 changed the title Topotato docstring pre commit linting Topotato docstring linting Sep 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant