johnklee / fpu

Functional programming utility
MIT License
4 stars 4 forks source link

make flake8 support `max-line-length` and `doctest`, with `stataistics` count at the end #35

Closed wkCircle closed 1 year ago

wkCircle commented 1 year ago

As specified in title, we will restore E501 error which alert user when max number of chars exceeds max-line-length. We also turn on flake8 check for example code in docstring (via doctests=true), and output total count of each error category (via statistics=true).

wkCircle commented 1 year ago

The following screenshot demos how flake8 captures lint errors in docstring when doctests=true (otherwise the error is not captured).

image

To fix the issue, the correct format should add triple dots to indicate the continual of the unfinished code statement:

"""
Examples:
  >>> fd = fl(
  ...   *[1, 2, 3]
  ... )
  >>> fd.sum()
  6
"""

Note, this example docstring is only for demo purpose and will be only pushed after the error is fixed. Note additionally that flake8 is NOT responsible to check if fd.sum() really sums to 6. (This might be handled either by pytest with pytest --doctest-modules fpu/, or via sphinx)