Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Nested classes and functions are not checked #13

Closed
JensRantil opened this issue Aug 9, 2012 · 5 comments
Closed

Nested classes and functions are not checked #13

JensRantil opened this issue Aug 9, 2012 · 5 comments

Comments

@JensRantil
Copy link
Contributor

If I check a file containing

class A:

    """Test documentation."""

    class B:
        pass

I notice that it will not complain that B does not contain any PyDoc. I guess this is incorrect behaviour?

@keleshev
Copy link
Contributor

keleshev commented Aug 9, 2012

This was intended by me, but nothing like that is mentioned in PEP257 itself.

For me a nested class (also nested function) is automatically something private, i.e. it is not necessary to document it, like a function that starts with an underscore.

Still not sure how pep257 should behave in this case, and in case of nested functions.

@JensRantil
Copy link
Contributor Author

The reason I filed the bug is that I tend to put class specific exceptions/errors nested in another class is they are only thrown by that class. Maybe doing it that way is not the Pythonic way of doing it, I don't know...

@adiroiban
Copy link

If nested stuff is private, then start its name with '_*' . I also use nested functions, a lot ... ex Twisted code.

@Nurdok
Copy link
Member

Nurdok commented Oct 12, 2015

My two cents on this issue:

Nested classes are public. They are public because names defined inside a class definitions are accessible from outside of the class, such as methods, class methods, class members, etc. For all of these, we consider them public unless they are prepended with an underscore.

Nested function are private. They are private because names inside a function definitions are not accessible from the outside, namely local variables.

@Nurdok
Copy link
Member

Nurdok commented Oct 12, 2015

Just to make it clear - in "nested class" I meant a class inside a class, not a class inside a function.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants