pep8-naming icon indicating copy to clipboard operation
pep8-naming copied to clipboard

Filename checks?

Open adamchainz opened this issue 5 years ago • 8 comments

PEP 8 states:

Modules should have short, all-lowercase names.

pycodestyle could check the passed filenames are lowercase to help enforce this.

adamchainz avatar Jan 13 '20 13:01 adamchainz

(Apologies if this isn't new, I couldn't find any existing issue but there are quite a few terms to search/filter so might have missed one)

adamchainz avatar Jan 13 '20 13:01 adamchainz

Except that sometimes things are passed on standard in and many modules use _ these days which sounds like it's against the PEP. So I'd say the de facto standard is quite different from the written standard.

sigmavirus24 avatar Jan 13 '20 23:01 sigmavirus24

this may be something better accomplished through pep8-naming?

asottile avatar Jan 13 '20 23:01 asottile

@sigmavirus24 _ is not against the PEP, sorry the full text is:

Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability. Python packages should also have short, all-lowercase names, although the use of underscores is discouraged.

pycodestyle could only check for uppercase characters. These cause problems porting code from a case insensitive to case sensitive filesystem, and the main reason I opened this issue.

I appreciate the name can't be checked from stdin.

@asottile Yes it could be in that project instead.

adamchainz avatar Jan 14 '20 16:01 adamchainz

I transferred this over to pep8-naming since we were all in agreement about where it belonged.

sigmavirus24 avatar Jan 14 '20 21:01 sigmavirus24

JFYI: a lot of module-level checks are covered in wemake-python-styleguide that uses pep8-naming as a dependency.

sobolevn avatar Mar 08 '20 13:03 sobolevn

There are also two flake8 plugins that are related to this feature, but it will be nice to have it in pep8-naming:

  • flake8-module-name. A flake8 plugin for testing PEP-8 conform package and module names.
  • flake8-filename. A flake8 linter plug-in for validating that certain files comply with a user defined pattern.

fpuga avatar Aug 15 '20 06:08 fpuga

flake8-filename says

This project is currently not actively maintained

sigmavirus24 avatar Aug 15 '20 14:08 sigmavirus24