flake8's "# noqa" interferes with markdown using mkdocstrings

411 views Asked by At

I am using mkdocstrings in order automatically generate an API documentation from my Python functions. At the same time I am using flake8 to keep my code in good shape.

If you want to ignore some flake8 warnings on an in-line basis, you could insert "# noqa" whereby the following lines of code will be ignored by flake8.

That's nice, however, "# noqa" will be interpreted by mkdocstrings as a markdown header.

Now, I am wondering how to resolve that conflict between flake8 and mkdocstrings?

1

There are 1 answers

0
anthony sottile On BEST ANSWER

put the noqa comment on the end of the docstring -- it will apply to any line within the docstring without changing the string's contents (note: you need a sufficiently new flake8, this change is relatively recent (probably >=4.x))

def f():
    """some docstring here

    something which causes a warning
    """  # noqa: ABC123

disclaimer: I am the current flake8 maintainer