flake8-spm
Flake8 plugin for finding issues with structural pattern matching
NOTE: this plugin is under development. Coming up soon!
Motivation
Structural pattern matching has been introduced in PEP 634 with the tutorial added in PEP 636.
The present plugin intends to catch default cases, which do not match any pattern, but do not raise an exception.
In the problematic example below we handle unexpected pattern as Default.
def func(value):
match value:
case 1:
return 'One'
case _:
return 'Default' # <-- ignoring exceptional case
However, for the non-matching cases we would better raise an error, to follow fail-fast methodology. Indeed, if we could not find a mathing pattern, then it is an unexpected event, and we need to raise an error, as shown below.
def func(value):
match value:
case 1:
return 'One'
case _:
raise ValueError(f'Unexpected case: {value}')
Then in the client code we would handle this error appropriately, instead of sweeping the issue under the rug.
List of warnings
SPM001: not raising when matching default value.
Installation (IN PROGRESS)
Install via pip with:
$ pip install flake8-spm
It will then automatically be run as part of flake8.
You can check is has been picked up via:
$ flake8 --version
Metadata
Release files for flake8-spm 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| flake8_spm-0.0.1.tar.gz | 5.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flake8_spm-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.0 kB
Release files / flake8_spm-0.0.1.tar.gz
| Download URL | flake8_spm-0.0.1.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f7151b15385bd9d5890be0ae8348cf58424710b345a4ae5bb5d1035570c2b0a9
|
|
BLAKE2b-256 checksum How to use checksums |
04253228c975a1e39ebeb7ebcdb45d4531cb4f5d11729a0eaa03584273a3f3e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.3
|
Release files / flake8_spm-0.0.1-py3-none-any.whl
| Download URL | flake8_spm-0.0.1-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7013423b5376ab2e04c0d96a7276e99aa218f5db9b397381562d7a6d3da6c9fb
|
|
BLAKE2b-256 checksum How to use checksums |
715f175e8041426fb3077c7e1968bb7c9d31bd3c921969dcdfb75f0b48850fdd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.3
|
Security for flake8-spm 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.