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

AttributeError when parameters are documented in the class docstring. #434

Closed
anntzer opened this issue Dec 9, 2019 · 7 comments
Closed

AttributeError when parameters are documented in the class docstring. #434

anntzer opened this issue Dec 9, 2019 · 7 comments

Comments

@anntzer
Copy link

@anntzer anntzer commented Dec 9, 2019

Running pydocstyle 5.0.0 on

class Blah:
    """
    Blah.

    Parameters
    ----------
    x : int
    """

    def __init__(self, x):
        pass

results in

<elided>
  File ".../lib/python3.8/site-packages/pydocstyle/checker.py", line 1002, in get_function_args
    function_arg_node = ast.parse(textwrap.dedent(function_string)).body[0].args
AttributeError: 'ClassDef' object has no attribute 'args'

One can argue whether parameter lists should be allowed on the class docstring rather than the init docstring, but in any case this shouldn't fail with an AttributeError.

@jbloom

This comment has been minimized.

Copy link

@jbloom jbloom commented Dec 9, 2019

Same problem for me. Code that was now passing linting fails.

jbloom added a commit to jbloomlab/alignparse that referenced this issue Dec 9, 2019
In the newest `pydocstyle` (5.0.0) there appears
to be a new bug that causes failures for parameters
documented in the class string:
PyCQA/pydocstyle#434

Adjust `test_requirements.txt` to specify **not** to
use this version of `pydocstyle`.
jbeezley added a commit to NutritionalLungImmunity/simulation-framework that referenced this issue Dec 9, 2019
@europ

This comment has been minimized.

Copy link

@europ europ commented Dec 9, 2019

I had the same problem by using pydocstyle 5.0.0.

@alanverdugo

This comment has been minimized.

Copy link

@alanverdugo alanverdugo commented Dec 9, 2019

I got the same problem here.

@Nurdok

This comment has been minimized.

Copy link
Member

@Nurdok Nurdok commented Dec 9, 2019

Thanks for reporting, and thanks for the reproducing example, it's really helpful! I'm working on a fix and will try to release 5.0.1 ASAP.

@Nurdok

This comment has been minimized.

Copy link
Member

@Nurdok Nurdok commented Dec 9, 2019

@anntzer @jbloom @europ @alanverdugo

I released 5.0.1 with a bugfix, hopefully that should do it.
I would highly appreciate it if you can try the new version and report back.

Thanks everyone!

@alanverdugo

This comment has been minimized.

Copy link

@alanverdugo alanverdugo commented Dec 9, 2019

All good now @Nurdok ! It works fine with 5.0.1
Thanks for fixing this so quickly! 🥇

@europ

This comment has been minimized.

Copy link

@europ europ commented Dec 9, 2019

@Nurdok I can confirm that release 5.0.1 works ✔️

Remarkable speed, thank you for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.