opennudge Python linter (naming conventions and other automated checks)
Project description
pynudger
opennudge Python linter (naming conventions and other automated checks)
✨ Features 🚀 Quick start 📚 Documentation 🤝 Contribute 👍 Adopters 📜 Legal
Features
pynudger is an opinionated linter for Python projects, focused on naming conventions and making your code "more Pythonic".
- Length rules: Too long class/function names are flagged.
- Setters/getters: Discourages usage of setters/getters, encourages properties instead.
- No helpers/utils/commons: Incentivizes more descriptive and semantically coherent names for functionalities.
Table of contents
Quick start
Installation
[!TIP] You can use your favorite package manager like
uv,hatchorpdminstead ofpip.
> pip install pynudger
Usage
To check against the rules run the following from the command line:
> pynudger check
You can pass additional arguments to pynudger check, like files
to check (by default all Python files in the current directory):
> pynudger check path/to/file.py another_file.py
Advanced
Configuration
You can configure pynudger in pyproject.toml (or .pynudger.toml
in the root of your project, just remove the [tool.pynudger] section),
for example:
[tool.pynudger]
# include rules by their code
include_codes = [1, 2, 5] # default: all rules included
# exclude rules by their code (takes precedence over include)
exclude_codes = [4, 5, 6] # default: no rules excluded
# whether to exit after first error or all errors
end_mode = "first" # default: "all"
[!TIP] Rule-specific configuration can be found in the section below.
Run as a pre-commit hook
pynudger can be used as a pre-commit hook, to add as a plugin:
repos:
- repo: "https://github.com/open-nudge/pynudger"
rev: ... # select the tag or revision you want, or run `pre-commit autoupdate`
hooks:
- id: "pynudger"
Disable in code
You can disable pynudger on a line-by-line basis
(you have to specify exact code), e.g.:
def set_my_too_long_function_name(): # noqa: PYNUDGER0, PYNUDGER16
pass
or a line span:
# noqa-start: PYNUDGER0, PYNUDGER16
def set_my_too_long_function_name():
pass
def set_another_long_function():
pass
# noqa-end: PYNUDGER0, PYNUDGER16
def set_will_error_out_this_time():
pass
It is also possible to disable all checks in a file by placing the following somewhere in the file (preferably at the top):
# noqa-file: PYNUDGER0, PYNUDGER16
[!NOTE] If you are running
pynudgerwithruffyou should addlint.external = ["PYNUDGER"]to[tool.ruff]section inpyproject.tomlto avoid removing# noqa: PYNUDGERcomments.
Rules
[!TIP] Run
pynudger rulesto see the list of available rules.
pynudger provides the following rules:
| Name | Description |
|---|---|
PYNUDGER0 |
Avoid using setters in class names. Use properties instead. |
PYNUDGER1 |
Avoid using setters in function names. Use properties instead. |
PYNUDGER2 |
Avoid using setters in file names. Define file name without it. |
PYNUDGER3 |
Avoid using getters in class names. Use properties instead. |
PYNUDGER4 |
Avoid using getters in function names. Use properties instead. |
PYNUDGER5 |
Avoid using getters in file names. Define file name without it. |
PYNUDGER6 |
Avoid using utils in class names. Name the class appropriately. |
PYNUDGER7 |
Avoid using utils in function names. Name the function appropriately. |
PYNUDGER8 |
Avoid defining utils modules. Move functionality to appropriate modules. |
PYNUDGER9 |
Avoid using helpers in class names. Name the class appropriately. |
PYNUDGER10 |
Avoid using helpers in function names. Name the function appropriately. |
PYNUDGER11 |
Avoid defining utils modules. Move functionality to appropriate modules. |
PYNUDGER12 |
Avoid using common in class names. Name the class appropriately. |
PYNUDGER13 |
Avoid using common in function names. Name the function appropriately. |
PYNUDGER14 |
Avoid defining common modules. Move functionality to appropriate modules. |
PYNUDGER15 |
Avoid long class names. Specify intent by nesting modules/packages. |
PYNUDGER16 |
Avoid long function names. Specify intent by nesting modules/packages. |
PYNUDGER17 |
Avoid long path names. Specify intent by nesting modules/packages. |
with the following configurable options (in pyproject.toml
or .pynudger.toml):
| Option | Description | Affected rules | Default |
|---|---|---|---|
pascal_length |
Maximum allowed length of PascalCase names | PYNUDGER15 | 3 |
snake_length |
Maximum allowed length of snake_case names | PYNUDGER16, PYNUDGER17 | 3 |
pascal_excludes |
List of words to exclude from PascalCase length check | PYNUDGER15 | [] |
snake_excludes |
List of words to exclude from snake_case length check | PYNUDGER16, PYNUDGER17 | [] |
Contribute
We welcome your contributions! Start here:
Legal
- This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
- This project is copyrighted by open-nudge - the appropriate copyright notice is included in each file.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pynudger-0.2.1.tar.gz.
File metadata
- Download URL: pynudger-0.2.1.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05af22e917e0be18e839258ee11b40a196ca34b61df82735da413ac532422834
|
|
| MD5 |
376ba4f7b43005d6efd6f515d40aac3e
|
|
| BLAKE2b-256 |
03118607f152da0d243e9f8c9e39beccd4e3ea82a37c37843e21d0bc9681afb7
|
Provenance
The following attestation bundles were made for pynudger-0.2.1.tar.gz:
Publisher:
release.yml on open-nudge/pynudger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pynudger-0.2.1.tar.gz -
Subject digest:
05af22e917e0be18e839258ee11b40a196ca34b61df82735da413ac532422834 - Sigstore transparency entry: 533529832
- Sigstore integration time:
-
Permalink:
open-nudge/pynudger@4e6b6ad9711b1226e00d61cb5094ba7199423441 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/open-nudge
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4e6b6ad9711b1226e00d61cb5094ba7199423441 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pynudger-0.2.1-py3-none-any.whl.
File metadata
- Download URL: pynudger-0.2.1-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88af7e302924d9222f39a89868d23b35b0f3898fa4f7cab094a94c408cadefca
|
|
| MD5 |
c2f29b372ef13d71052d291077706a93
|
|
| BLAKE2b-256 |
3d3b2833fc509b4f50c6b911f99988c0bbacc7565c9d087fd3ff2493628e9d67
|
Provenance
The following attestation bundles were made for pynudger-0.2.1-py3-none-any.whl:
Publisher:
release.yml on open-nudge/pynudger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pynudger-0.2.1-py3-none-any.whl -
Subject digest:
88af7e302924d9222f39a89868d23b35b0f3898fa4f7cab094a94c408cadefca - Sigstore transparency entry: 533529834
- Sigstore integration time:
-
Permalink:
open-nudge/pynudger@4e6b6ad9711b1226e00d61cb5094ba7199423441 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/open-nudge
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4e6b6ad9711b1226e00d61cb5094ba7199423441 -
Trigger Event:
release
-
Statement type: