Metadata-Version: 2.4
Name: flake8-spm
Version: 0.0.1
Summary: Flake8 plugin for structural pattern matching
Project-URL: Homepage, https://github.com/ivanovmg/flake8-spm
Project-URL: Issues, https://github.com/ivanovmg/flake8-spm/issues
Author-email: Maxim Ivanov <ivanovmg@gmail.com>
License-File: LICENSE
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Framework :: Flake8
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# 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](https://peps.python.org/pep-0634/)
with the tutorial added in [PEP 636](https://peps.python.org/pep-0636/).

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`.

``` python
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.

``` python
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
```
