('An extension for flake8 that validates functions names, decomposition and conformity with annotations.',)
Project description
flake8-functions-names
DISCLAIMER: this is DDD project, so at the moment the documentation lies. If you're interested in the project, write me a note (t.me/melevir).
An extension for flake8 that validates functions names, decomposition and conformity with annotations. The plugin also has some validations of deal contracts.
This plugin helps to provide better naming for functions. The validations are based on my articles:
deal
-related validations are enabled only if deal
is installed.
They are disabled otherwise.
Installation
pip install flake8-functions-names
Example
def is_user_banned(user: User) -> str:
return 'is_banned' if user.id in BANNED_USERS else 'not_banned'
def save_user(user: User) -> None:
user.save()
Usage:
$ flake8 test.py
text.py:1:35: FNE001 Name of function says, that is should return bool, but it returns str
text.py:4:4: FNE003 Name of the function uses "save", but not uses "to"
Tested on Python 3.8+ and flake8 3.9+.
Error codes
Error code | Description |
---|---|
FNE001 | Name of the function says, that is should return bool, but it returns actual_type |
FNE002 | The method has a @property decorator, but has verb in it's name (verb) |
FNE003 | Name of the function uses "save", but not uses "to" |
FNE004 | Name of the function uses "load", but not uses "from" |
FNE005 | Return type of the function is bool, but the name doesn't shows it |
FNE006 | Name of function says, that it works with data, so it should be pure, but it has no @dead.pure() |
FNE007 | "and" is not recommended in functions names |
FNE008 | Name of functions endswith it's first argument name |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for flake8_functions_names-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7cd8a666b94abb2f8b62a6b6b3f43995a6c5ba09fe7bbceeb2e39114d8c53d6 |
|
MD5 | c4ea21a8e8cb320f1d6f7789e0502435 |
|
BLAKE2b-256 | 3d90bcfcec1bdbe33584fd2c794cde6f18cfe4e297741def525d866e30217df5 |