Nested classes and functions are not checked #13

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

Projects

None yet

4 participants

@JensRantil
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
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
Contributor

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

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

@Nurdok
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
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.

@Nurdok Nurdok closed this Oct 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment