Skip to main content

Arbitrary regex checker, extension for flake8

Project description

# flake8-regex
Searches for regex patterns provided in a configuration file

## Usage

These steps are tested using Mac OSX 10.10.5 and python 3.4.2

1- Get flake8 and flake8-regex:

```
pip install flake8 flake8-regex
```

2- Create a config module such as

**file**: your_config_module.py

```
import re

rules = [
{
'regex': re.compile(r"""(^simple.*|
^pattern.*)""", re.X),
'code': '100', # Any 3 digit code, 'R' namespace will be prefixed to that in the report
'message': "neither 'simple' nor 'pattern' are allowed at the beginning of a line",
},
]

```
**Important note**: The config file can be named anything, but the list MUST be named `rules`

3- Set a FLAKE8_REGEX_CONFIG_MODULE environment variable

```
export FLAKE8_REGEX_CONFIG_MODULE=absolute.path.to.your_config_module
```

4- run it!

For example:

**for file**: code.py

```
simple = "foo"
pattern = "bar"
good = None
```

```
flake8 code.py

code.py:1:1: R100 neither 'simple' nor 'pattern' are allowed at the beginning of a line
code.py:2:1: R100 neither 'simple' nor 'pattern' are allowed at the beginning of a line
```

## Known issues

The current implementation only reports the first item in the list of rules that matches the line
evaluated. In the future all matching items will be reported.

Project details


Release history Release notifications | RSS feed

This version

0.3

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flake8-regex-0.3.tar.gz (2.7 kB view details)

Uploaded Source

File details

Details for the file flake8-regex-0.3.tar.gz.

File metadata

  • Download URL: flake8-regex-0.3.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for flake8-regex-0.3.tar.gz
Algorithm Hash digest
SHA256 812e6f9cfc66f3b8ad2bbb93ec0dede2043a16b5f5d04dc1c8f8e3590c7e67bd
MD5 3b37e22e3f61306fc69c0937fff56afd
BLAKE2b-256 6a9f77394c31f7c51f07c78b0a2b2fad5b348775ce49d95e2e531d201d26d732

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