Skip to main content

Fast Python linter for catching LLM-generated anti-patterns

Project description

slopcop

A fast, opinionated Python linter written in Rust that catches anti-patterns commonly produced by language models.

Built on tree-sitter for AST-correct analysis — no false positives on strings or comments.

Install

# From source (requires Rust toolchain)
cargo install --git https://github.com/cm2435/slopcop

# Or clone and build
git clone https://github.com/cm2435/slopcop && cd slopcop && cargo install --path .

PyPI and crates.io packages coming soon (pip install slopcop).

Usage

# Lint directories (walks recursively for .py files)
slopcop src/ tests/

# Lint specific files
slopcop path/to/file.py

# Quiet mode (exit code only, for CI)
slopcop --quiet src/

# JSON output
slopcop --format json src/

# Only fail on errors, treat warnings as non-blocking
slopcop --warn-only src/

Exit codes: 0 = clean, 1 = violations found, 2 = fatal error.

Rules

All rules are enabled by default. Disable per-project via pyproject.toml.

Rule What it catches
no-hasattr-getattr hasattr() and getattr() calls — use explicit attribute checks or protocols
guarded-function-import Function-scope import without a comment on the line above explaining why
no-future-annotations from __future__ import annotations — unnecessary on 3.13+ and breaks runtime inspection
no-dataclass @dataclass usage and dataclasses imports — use Pydantic or project-standard models
no-bare-except except: without a type — catches everything including KeyboardInterrupt
no-broad-except except Exception: / except BaseException: — too broad, catch specific types
no-pass-except except blocks containing only pass — silently swallows exceptions
no-nested-try Nested try blocks — extract the inner try into a separate function
no-print print() calls — use structured logging
no-todo-comment TODO, FIXME, HACK, XXX comments — resolve or track in an issue
no-assert assert in production code — use if not ...: raise ValueError(...) instead
no-typing-any Any in type annotations — use specific types or protocols
no-str-empty-default str = "" defaults on params and model fields — use str | None = None or make required
no-boolean-positional Bare True/False as positional arguments — use keyword arguments for clarity
no-redundant-none-check x is None when x is typed as non-optional
max-function-params Functions with more than 8 parameters (configurable) — group into a model

Configuration

Add [tool.slopcop] to your pyproject.toml:

[tool.slopcop]
exclude = [
    "no-dataclass",   # this project uses dataclasses
    "no-print",       # CLI app, print is fine
]

Per-file ignores

Disable rules for specific file patterns:

[tool.slopcop.per-file-ignores]
"tests/**" = ["no-print"]
"**/cli/**" = ["no-print"]

Rule-specific config

[tool.slopcop.rules.max-function-params]
max = 10

slopcop walks upward from the target path to find the nearest pyproject.toml.

Inline suppression

x = getattr(obj, name)                     # slopcop: ignore
x = getattr(obj, name)                     # slopcop: ignore[no-hasattr-getattr]
x = getattr(obj, name)                     # slopcop: ignore[no-hasattr-getattr, no-print]

Adding to CI

# GitHub Actions
- name: Install slopcop
  run: cargo install --git https://github.com/cm2435/slopcop

- name: Lint
  run: slopcop src/ tests/

Development

cargo test          # run the test suite
cargo run -- src/   # run locally

License

MIT

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

slopcop-0.1.0.tar.gz (28.5 kB view details)

Uploaded Source

Built Distributions

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

slopcop-0.1.0-py3-none-win_amd64.whl (1.4 MB view details)

Uploaded Python 3Windows x86-64

slopcop-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

slopcop-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.7 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

slopcop-0.1.0-py3-none-macosx_11_0_arm64.whl (1.6 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

slopcop-0.1.0-py3-none-macosx_10_12_x86_64.whl (1.6 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file slopcop-0.1.0.tar.gz.

File metadata

  • Download URL: slopcop-0.1.0.tar.gz
  • Upload date:
  • Size: 28.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.12.6

File hashes

Hashes for slopcop-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9160cbfbb597b64e6c1c50e9a598a22f135595ea830843ddb71313b89bd809bf
MD5 0e8888382032755c028202546cb66fcf
BLAKE2b-256 44b5996fdfffdffff41b06e24e1d8d1189f2fc728aab38a9b79a964b8a385f6b

See more details on using hashes here.

File details

Details for the file slopcop-0.1.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: slopcop-0.1.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.12.6

File hashes

Hashes for slopcop-0.1.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 270cfd966ccf1ee97d8abbb1901a4db08461f83e7c54c776e86258bd59c7acd5
MD5 a3d601ee25ccdb185f3949db9860235c
BLAKE2b-256 1922e3590d68ad9476e6003e6cf8deb9f94f6c2d33e69a4ec880f248bd5ef586

See more details on using hashes here.

File details

Details for the file slopcop-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for slopcop-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 236bcbb35f62fdf701d36255d2b2d5924cc2f8d0dc200dd7dd01dab12537be45
MD5 4bb83d8144a40b43fdff62e3dec98e60
BLAKE2b-256 7b5467b37719185426f9e5387a8c0d374cd58ea8103a767345a7edc45c106d4f

See more details on using hashes here.

File details

Details for the file slopcop-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for slopcop-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 00c6ed4052ae6372d06e9481485600ffe8875443300483953bcc2659fdc132be
MD5 ba8d2236034596e05bec8908cde7f89e
BLAKE2b-256 58ebf1c08a4014d122b44de69cd09e1d259505598ba2c04b3c3217e0b5b107ed

See more details on using hashes here.

File details

Details for the file slopcop-0.1.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for slopcop-0.1.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 df04024429806bbeb8409f08f8b49f7afce7577f71e78b4cf76af900fa0ec550
MD5 e0b00db09521c6f9959eeb74809a8b84
BLAKE2b-256 203344206ac4211ef4105d07c8304ba0d995580198be70dd45c1516c6722b483

See more details on using hashes here.

File details

Details for the file slopcop-0.1.0-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for slopcop-0.1.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d8fc41506e2e01ef0f467ff20821dc24bf8a9423c76724c187939857e534f14a
MD5 89d52152e556ad663c894c0dcb8e9469
BLAKE2b-256 bf54c90116a4726577a92e34a6b043952664f736b896465f8f970dc1151f7260

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