Skip to main content

CLASP 3.0 / PEP 2606 Static Analysis Tool — enforces naming and comment conventions beyond PEP 8.

Project description

CLASPLint

Python License PyPI

CLASP 3.0 / PEP 2606 static analysis tool. Enforces naming and comment conventions beyond PEP 8 — checks variables, dictionary keys, functions, classes, comments, and log messages for standards compliance.


Features

  • Variable namesgroup1_group2 format, all lowercase, no abbreviations, type/boolean prefixes, ≤30 chars
  • Dictionary keys — PascalCase, full spelling, acronyms kept uppercase
  • Function & class names — snake_case for functions, PascalCase for classes, private methods _init_X_function_
  • Comment format — every physical code line requires # Capitalized sentence. comment (import/class/def exempt)
  • Log messages — pre-defined string variables, proper try-except chains, exc_info=True on errors
  • Docstrings — presence check for all functions and classes; Sphinx :param/:type/:return format enforcement for methods with detailed description requirement

Installation

pip install CLASPLint

Or from source:

git clone https://github.com/thedayofthedoctor/clasplint.git
cd clasplint
pip install -e .

Quick Start

# Check a single file
CLASPLint path/to/file.py

# Check all Python files in a directory (recursive)
CLASPLint src/

# Show only summary, no per-violation output
CLASPLint --quiet src/

# Filter by violation category
CLASPLint --category variable src/

Usage

usage: CLASPLint [-h] [--version] [--no-recursive] [--quiet] [-c CATEGORY] [paths ...]

positional arguments:
  paths                 Python files or directories to check (default: current directory)

options:
  --version             show version number and exit
  --no-recursive        do not recursively check subdirectories
  --quiet, -q           suppress individual violation output; show only summary
  --category, -c {variable,dict_key,function,comment,log,docstring}
                        only report violations of a specific category

Example Output

$ CLASPLint tests/test_violations.py

CLASPLint: 30 violation(s) in 1 of 1 file(s).
  comment: 8
  dict_key: 4
  function: 3
  log: 4
  variable: 11

  tests/test_violations.py:8  [variable] Variable 'badvar' must have exactly one underscore ...
  tests/test_violations.py:11 [variable] Variable 'Bad_Var' contains uppercase letters ...
  ...

CLASP 3.0 / PEP 2606 Rules Summary

Category Rule
Variable group1_group2, one underscore, all lowercase, no abbreviations, ≤30 chars
Boolean is_ or has_ prefix
Dict Key PascalCase, full spelling, acronyms uppercase (GPS, UTM, XML, etc.)
Class PascalCase
Function snake_case, specific verb, ≤30 chars
Method Public: short snake_case; Private: _init_X_function_ ≤30 chars
Comment Every physical line: # Capitalized sentence ending with period. (import/class/def exempt)
Log Messages as variables, proper try-except logging chain, exc_info=True
Docstring Presence required; Sphinx :param/:type/:return format for methods with detail section

Python Version Support

CLASPLint supports Python 3.8 through 3.13+. The minimum version is 3.8 due to ast.Constant, ast.NamedExpr, and ast.get_docstring() usage.

License

GPL-3.0-only — Copyright (C) 2026 Matt Belfast Brown



CLASPLint(中文)

Python License PyPI

CLASP 3.0 / PEP 2606 静态分析工具。在 PEP 8 之上强制执行命名与注释规范 —— 检查变量、字典键、函数、类、注释和日志消息是否符合标准。


功能特性

  • 变量名 —— group1_group2 两段下划线格式,全部小写,禁止缩写,支持类型/布尔前缀,≤30 字符
  • 字典键名 —— PascalCase 驼峰式,完整拼写,专有缩写保持大写
  • 函数与类名 —— 函数 snake_case,类 PascalCase,私有方法 _init_X_function_
  • 注释格式 —— 每条物理代码行前必须有 # 首字母大写英文句子并以句号结尾。(import/class/def 豁免)
  • 日志消息 —— 必须预定义为字符串变量,完整的 try-except 链条,错误日志带 exc_info=True
  • 文档字符串 —— 函数和类必须存在;方法需遵循 Sphinx :param/:type/:return 格式,并包含详细逻辑描述段落

安装

pip install CLASPLint

或从源码安装:

git clone https://github.com/thedayofthedoctor/clasplint.git
cd clasplint
pip install -e .

快速开始

# 检查单个文件
CLASPLint path/to/file.py

# 递归检查目录下所有 Python 文件
CLASPLint src/

# 仅显示摘要,不输出逐条违规
CLASPLint --quiet src/

# 按类别过滤
CLASPLint --category variable src/

命令行用法

usage: CLASPLint [-h] [--version] [--no-recursive] [--quiet] [-c CATEGORY] [paths ...]

位置参数:
  paths                 要检查的 Python 文件或目录(默认:当前目录)

可选参数:
  --version             显示版本号并退出
  --no-recursive        不递归检查子目录
  --quiet, -q           仅显示摘要,抑制逐条违规输出
  --category, -c {variable,dict_key,function,comment,log,docstring}
                        仅报告指定类别的违规

输出示例

$ CLASPLint tests/test_violations.py

CLASPLint: 30 violation(s) in 1 of 1 file(s).
  comment: 8
  dict_key: 4
  function: 3
  log: 4
  variable: 11

  tests/test_violations.py:8  [variable] Variable 'badvar' must have exactly one underscore ...
  tests/test_violations.py:11 [variable] Variable 'Bad_Var' contains uppercase letters ...
  ...

CLASP 3.0 / PEP 2606 规则速查

类别 规则
变量 group1_group2,有且仅有一个下划线,全部小写,禁止缩写,≤30 字符
布尔值 is_has_ 前缀
字典键 PascalCase 驼峰式,完整拼写,专有缩写大写(GPS、UTM、XML 等)
类名 PascalCase
函数名 snake_case,使用具体动词,≤30 字符
方法 公共:简短 snake_case;私有:_init_X_function_ ≤30 字符
注释 每条物理行:# Capitalized sentence ending with period.(import/class/def 豁免)
日志 消息预定义为变量,完整 try-except 日志链,exc_info=True
文档字符串 必须存在;方法需 Sphinx :param/:type/:return 格式并包含详细段落

Python 版本支持

CLASPLint 支持 Python 3.8 至 3.14+。最低版本为 3.8,原因在于使用了 ast.Constantast.NamedExprast.get_docstring()

许可证

GPL-3.0-only — Copyright (C) 2026 Matt Belfast Brown

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

clasplint-0.2.0.tar.gz (33.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

clasplint-0.2.0-cp314-none-any.whl (45.9 kB view details)

Uploaded CPython 3.14

clasplint-0.2.0-cp313-none-any.whl (45.9 kB view details)

Uploaded CPython 3.13

clasplint-0.2.0-cp312-none-any.whl (45.9 kB view details)

Uploaded CPython 3.12

clasplint-0.2.0-cp311-none-any.whl (45.9 kB view details)

Uploaded CPython 3.11

clasplint-0.2.0-cp310-none-any.whl (45.9 kB view details)

Uploaded CPython 3.10

clasplint-0.2.0-cp39-none-any.whl (45.9 kB view details)

Uploaded CPython 3.9

clasplint-0.2.0-cp38-none-any.whl (45.8 kB view details)

Uploaded CPython 3.8

File details

Details for the file clasplint-0.2.0.tar.gz.

File metadata

  • Download URL: clasplint-0.2.0.tar.gz
  • Upload date:
  • Size: 33.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for clasplint-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b5a55435d7fd64a630e084acec73a97480ffdd31552638d4a446ae79161562f5
MD5 5e09a8299dd1357a65140f398f260370
BLAKE2b-256 f7dd83a7b76b7c8b810528529dfda2477a93b32bc3249b66f965799509cd51e7

See more details on using hashes here.

File details

Details for the file clasplint-0.2.0-cp314-none-any.whl.

File metadata

  • Download URL: clasplint-0.2.0-cp314-none-any.whl
  • Upload date:
  • Size: 45.9 kB
  • Tags: CPython 3.14
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for clasplint-0.2.0-cp314-none-any.whl
Algorithm Hash digest
SHA256 f6a85fd540eb8c9119f52777bd70cfa224bd30ccbca54cdfc93398dcc2a8da60
MD5 1bcfa14ddc1ad1cd9a4aea5d16310372
BLAKE2b-256 341868046898169eb04ba35269b3c8ec7e0bb53582be72999776b567c66b4f5e

See more details on using hashes here.

File details

Details for the file clasplint-0.2.0-cp313-none-any.whl.

File metadata

  • Download URL: clasplint-0.2.0-cp313-none-any.whl
  • Upload date:
  • Size: 45.9 kB
  • Tags: CPython 3.13
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for clasplint-0.2.0-cp313-none-any.whl
Algorithm Hash digest
SHA256 ded5176503cc10b4b78fd3e5d50eaca836eca1bd1db86fe741a70e047a282fd8
MD5 851c345f31a9ddf4f605912c290619e3
BLAKE2b-256 54a5df40bd24355be47fa10712d1409beb9a5e9c704ec053b090633a6eb7863d

See more details on using hashes here.

File details

Details for the file clasplint-0.2.0-cp312-none-any.whl.

File metadata

  • Download URL: clasplint-0.2.0-cp312-none-any.whl
  • Upload date:
  • Size: 45.9 kB
  • Tags: CPython 3.12
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for clasplint-0.2.0-cp312-none-any.whl
Algorithm Hash digest
SHA256 504f1737825c04db61dcbcf890c033a92f5b0485329a9dd740f1d643dc7220bf
MD5 449cb0d3d55f740464646fb4f20320f3
BLAKE2b-256 091fce2ceea1124f0851cef99ccd548e928916135635fb1b13ddfe1715f9c782

See more details on using hashes here.

File details

Details for the file clasplint-0.2.0-cp311-none-any.whl.

File metadata

  • Download URL: clasplint-0.2.0-cp311-none-any.whl
  • Upload date:
  • Size: 45.9 kB
  • Tags: CPython 3.11
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for clasplint-0.2.0-cp311-none-any.whl
Algorithm Hash digest
SHA256 d072d40e690a7bc50d64aafa5a142770c9187a62d4d8846b29459d082d9f6a85
MD5 a087487093b9584ae0ef2f3f2474374c
BLAKE2b-256 b496ac258f11cd6fc0447dd5e5b91af8b2a2a50c04bb8444a5c0f9f036b0b9a6

See more details on using hashes here.

File details

Details for the file clasplint-0.2.0-cp310-none-any.whl.

File metadata

  • Download URL: clasplint-0.2.0-cp310-none-any.whl
  • Upload date:
  • Size: 45.9 kB
  • Tags: CPython 3.10
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for clasplint-0.2.0-cp310-none-any.whl
Algorithm Hash digest
SHA256 5525841a700fa2b5ca0da18c58bcc05dc9eccb4b1a10acc560f4ee0b744fc819
MD5 97c50839ed060168bfc7d071004c0a35
BLAKE2b-256 7f6f3b65ec6ce5c98db688b3af288b9e19fc7239699f25fd8cedc6827f1660a6

See more details on using hashes here.

File details

Details for the file clasplint-0.2.0-cp39-none-any.whl.

File metadata

  • Download URL: clasplint-0.2.0-cp39-none-any.whl
  • Upload date:
  • Size: 45.9 kB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for clasplint-0.2.0-cp39-none-any.whl
Algorithm Hash digest
SHA256 5d95416771a3c2d63d9e0aa7840862632172c93848b577ce136517671c3a2f25
MD5 59eda4cf249e9c9334f6b4c4c61a0c3f
BLAKE2b-256 481cd71aa2dc4ba7a300c7262e78122e668f8f4276544cb15a2f131322843af3

See more details on using hashes here.

File details

Details for the file clasplint-0.2.0-cp38-none-any.whl.

File metadata

  • Download URL: clasplint-0.2.0-cp38-none-any.whl
  • Upload date:
  • Size: 45.8 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for clasplint-0.2.0-cp38-none-any.whl
Algorithm Hash digest
SHA256 c172441cedcb9880735f155b1160b60779ab30e43d627d822ce6e2aca70cee08
MD5 aebc43f532a8e11362b4c9d9b2479945
BLAKE2b-256 b5289c5aaded8a417c53f811cf66dcf75a9fe130114c1ed57c43130c1fc1b259

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page