Skip to main content

Stephen Lints Your Python

Project description

SLYP

Stephen Lints Your Python

An opinionated linter and fixer.

PyPI - Version PyPI - Python Version


Table of Contents

Hi

:wave:

I'm Stephen. I'm going to lint (and fix) your Python code.

I wrote this linter because nothing else out there implemented these rules, and some of them needed CST (rather than AST), so there was no plugin framework (e.g. flake8 plugins) which I could use.

I hope it helps you.

Installation

slyp is a python package and can be run as a pre-commit hook.

On supported python versions, it should be installed with

pip install slyp

Usage

Either use it as a CLI tool:

slyp

Or as a pre-commit hook using the following pre-commit-config.yaml:

- repo: https://github.com/sirosen/slyp
  rev: 0.6.0
  hooks:
    - id: slyp

Options and Arguments

[files...]: If passed positional arguments, slyp will treat them as filenames to check. Otherwise, it will search the current directory for python files.

-v/--verbose: Enable more verbose output

--use-git-ls: Find files to check by doing a git ls-files call and filtering the results to files which appear to be python. This is mutually exclusive with any filename arguments.

--disable CODES: Pass a comma-delimited list of codes to turn off.

--enable CODES: Pass a comma-delimited list of codes to turn on.

Implemented Rules

E is for "error" (you should probably change this)

W is for "warning" (you might want to change this)

Some warnings are disabled by default; enable them with --enable.

E100

'unnecessary string concat'

x = "foo " "bar"

E101

'unnecessary string concat with plus'

x = "foo " + "bar"

W200

'two AST branches have identical contents'

if x is True:
    return y + 1
else:
    # some comment
    return y + 1

W201

disabled by default

'two AST branches have identical trivial contents'

if x is True:
    return
else:
    return

W202

disabled by default

'two non-adjacent AST branches have identical contents'

if x is True:
    return foo(bar())
elif y is True:
    return 0
elif z is True:
    return 1
else:
    return foo(bar())

W203

disabled by default

'two non-adjacent AST branches have identical trivial contents'

if x is True:
    return None
elif y is True:
    return 0
elif z is True:
    return 1
else:
    return None

License

slyp is distributed under the terms of the MIT license.

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

slyp-0.6.0.tar.gz (29.0 kB view details)

Uploaded Source

Built Distribution

slyp-0.6.0-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file slyp-0.6.0.tar.gz.

File metadata

  • Download URL: slyp-0.6.0.tar.gz
  • Upload date:
  • Size: 29.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for slyp-0.6.0.tar.gz
Algorithm Hash digest
SHA256 bc38e907c789c4258e54729bba18021c58f42772a237179b60f6f2f297917623
MD5 ebf491bdb9f8745b4ee07ad0b358bfe5
BLAKE2b-256 2e612d9d431ec2d829dae8e8a74839d64db5ce26c48d9878a122a65a737a548e

See more details on using hashes here.

Provenance

File details

Details for the file slyp-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: slyp-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for slyp-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dd3c3a82127b150055229fb8a33e3b9ae7dcb1411ceeaa39b90a32cd00421ea1
MD5 b646e27d02aaf8baa7163338d876b803
BLAKE2b-256 dac1dc5afcb3f5aa212b0680ae86654a48911c4b509f971c48782dd76d1d45d0

See more details on using hashes here.

Provenance

Supported by

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