Closed staticdev closed 4 years ago
I think this is actually an error in that example docstring. Each of the docstrings in the document uses a different indentation scheme. This one indents by 4 spaces, except for hanging lines. The next one in the document indents by 2 spaces.
Darglint raises a style error when it doesn't encounter consistent indentation (you can set the level in the config with indentation=2
). If you don't care about having consistent indentation for hanging lines, you can always just ignore that particular style error.
Unfortunately, it looks like there's a bug in the ignoring errors, where style errors aren't ignored. (See Issue #118). I'll leave this open until I submit the fix for that error (probably today.)
@terrencepreilly I was able to ignore it in this commit https://github.com/staticdev/django-pagination-bootstrap/pull/138/files
Great!
@terrencepreilly so if it is a problem with example docstring how should I fix this docstring?
I tried indenting with four spaces and still didn't fix:
def paginate(context, window=DEFAULT_WINDOW, hashtag=""):
"""Render the pagination.html template.
Args:
context:
Dictionary-like data structure and must contain the following keys
paginator - a ``Paginator`` or ``QuerySetPaginator`` object.
page_obj - the result of calling the page method on the
aforementioned ``Paginator`` or ``QuerySetPaginator`` object, given
the current page.
getvars (optional) - a dictionary of all of the **GET** parameters in the current request.
This is useful to maintain certain types of state, even when requesting
a different page.
window:
Optional. Defaults to DEFAULT_WINDOW.
hashtag:
Optional. Defaults to "".
Returns:
A Digg-like display of the available pages, given the current page.
If there are too many pages to be displayed before and after the current page, then
elipses will be used to indicate the undisplayed gap between page numbers.
"""
You're missing a blank line between sections. It should be
def paginate(context, window=DEFAULT_WINDOW, hashtag=""):
"""Render the pagination.html template.
Args:
context:
Dictionary-like data structure and must contain the following keys
paginator - a ``Paginator`` or ``QuerySetPaginator`` object.
page_obj - the result of calling the page method on the
aforementioned ``Paginator`` or ``QuerySetPaginator`` object, given
the current page.
getvars (optional) - a dictionary of all of the **GET** parameters in the current request.
This is useful to maintain certain types of state, even when requesting
a different page.
window:
Optional. Defaults to DEFAULT_WINDOW.
hashtag:
Optional. Defaults to "".
Returns:
A Digg-like display of the available pages, given the current page.
If there are too many pages to be displayed before and after the current page, then
elipses will be used to indicate the undisplayed gap between page numbers.
"""
...
That worked, thanks @terrencepreilly!
I am using darlint 1.5.1 with the official Google Style example from https://google.github.io/styleguide/pyguide.html#383-functions-and-methods - fetch_smalltable_rows first example:
It is giving error DAR003 on Args:
DAR003 Incorrect indentation: ~<