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

[Bug] D100: Module Containing Single Leading Underscore Considered Public #493

Closed
gbroques opened this issue Jul 19, 2020 · 4 comments
Closed

Comments

@gbroques
Copy link
Contributor

gbroques commented Jul 19, 2020

Issue: Receive "D100: Missing docstring in public module" error for module containing single leading underscore.

pydocstyle version: 5.0.2
python version: 3.8.4

From How publicity is determined:

Publicity for all constructs is determined as follows: a construct is considered public if -

  • Its immediate parent is public and
  • Its name does not contain a single leading underscore.

How to Reproduce

Consider the following simple example.

publicpackage/
├── __init__.py
└── _privatemodule.py  # D100: Missing docstring in public module

Within publicpackage/__init__.py:

"""Some docstring."""
from ._privatemodule import public_function_in_private_module

__all__ = ['public_function_in_private_module']

Within publicpackage/_privatemodule.py:

def public_function_in_private_module():
    """Public function in private module docstring."""
    pass
$ pydocstyle publicpackage      
publicpackage/_privatemodule.py:1 at module level:
        D100: Missing docstring in public module

Expected Behavior

_privatemodule contains single leading underscore, and would be considered private, not public.

Related Issues

@gbroques gbroques changed the title D100: Module with Single Leading Underscore Considered Public Module Containing Single Leading Underscore Considered Public Jul 19, 2020
@gbroques gbroques changed the title Module Containing Single Leading Underscore Considered Public D100: Module Containing Single Leading Underscore Considered Public Jul 19, 2020
@gbroques gbroques changed the title D100: Module Containing Single Leading Underscore Considered Public [Bug] D100: Module Containing Single Leading Underscore Considered Public Jul 19, 2020
@samj1912
Copy link
Member

related pr #470

@gbroques
Copy link
Contributor Author

gbroques commented Jul 19, 2020

related pr #470

@samj1912 Opened #494 as a continuation of work in #470.

@FrancescoCasalegno
Copy link

I just had the same error.

samj1912 added a commit that referenced this issue Aug 22, 2020
* Fix Module.is_public() when the module is not a the root

* Add PR reference

* Use pathlib

* Use pathlib instead of os for test_module_publicity

* Update release notes for #493

* Use forward slash '/' operator instead of .joinpath()

* Fix pull-request number in release notes

* Fix publicity of module in private package

* Update test_module_publicity docstring

* Add test for directory starting with double underscore

* Make packages containing double-underscore public

* Add test to assert __init__ module is public

* Make modules in a __private_package private

* Fix lint errors from lines being too long

* Update publicity.rst with more information

* Parameterize module publicity tests and include .py file extension in test path parameters

* Make module publicity determination respect $PYTHONPATH

* Fix line-length issue

* Reword comment

* Add tests with the same path over different sys.path cases

* Add note about checking sys.path for determining publicity

* Apply suggestions from code review

Co-authored-by: Thibault Derousseaux <tibdex@gmail.com>
Co-authored-by: Thibault Derousseaux <6574550+tibdex@users.noreply.github.com>
Co-authored-by: Sambhav Kothari <sambhavs.email@gmail.com>
@samj1912
Copy link
Member

Closed via #494

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

3 participants