flake8-ic 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- flake8_ic/__init__.py +3 -0
- flake8_ic/checker.py +41 -0
- flake8_ic/metadata.py +19 -0
- flake8_ic-0.1.0.dist-info/METADATA +93 -0
- flake8_ic-0.1.0.dist-info/RECORD +7 -0
- flake8_ic-0.1.0.dist-info/WHEEL +4 -0
- flake8_ic-0.1.0.dist-info/licenses/LICENSE +21 -0
flake8_ic/__init__.py
ADDED
flake8_ic/checker.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import ast
|
|
2
|
+
from typing import Generator, Tuple
|
|
3
|
+
|
|
4
|
+
from flake8_ic.metadata import get_project_metadata
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class IcecreamChecker:
|
|
8
|
+
"""
|
|
9
|
+
Flake8 plugin to check for usage of the `ic()` method from the `icecream` package.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
IC_ERROR_CODE = "IC100"
|
|
13
|
+
|
|
14
|
+
def __init__(self, tree: ast.Module):
|
|
15
|
+
self.tree = tree
|
|
16
|
+
self._load_metadata()
|
|
17
|
+
|
|
18
|
+
def _load_metadata(self) -> dict:
|
|
19
|
+
"""
|
|
20
|
+
Load the project metadata from the `pyproject.toml` file.
|
|
21
|
+
"""
|
|
22
|
+
metadata = get_project_metadata()
|
|
23
|
+
self.name = metadata["name"]
|
|
24
|
+
self.version = metadata["version"]
|
|
25
|
+
|
|
26
|
+
def run(self) -> Generator[Tuple[int, int, str, type], None, None]:
|
|
27
|
+
"""
|
|
28
|
+
Generator that yields issues found in the AST.
|
|
29
|
+
"""
|
|
30
|
+
for node in ast.walk(self.tree):
|
|
31
|
+
if isinstance(node, ast.Call) and isinstance(node.func, ast.Name):
|
|
32
|
+
if node.func.id == "ic":
|
|
33
|
+
yield (
|
|
34
|
+
node.lineno,
|
|
35
|
+
node.col_offset,
|
|
36
|
+
(
|
|
37
|
+
f"{self.IC_ERROR_CODE} Avoid using `ic()` from the "
|
|
38
|
+
"`icecream` package in production code."
|
|
39
|
+
),
|
|
40
|
+
type(self),
|
|
41
|
+
)
|
flake8_ic/metadata.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import toml
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def get_project_metadata():
|
|
5
|
+
"""
|
|
6
|
+
Load the project metadata from pyproject.toml.
|
|
7
|
+
Returns:
|
|
8
|
+
dict: Project metadata including name and version.
|
|
9
|
+
"""
|
|
10
|
+
try:
|
|
11
|
+
with open("pyproject.toml", "r", encoding="utf-8") as f:
|
|
12
|
+
pyproject = toml.load(f)
|
|
13
|
+
project = pyproject.get("project", {})
|
|
14
|
+
return {
|
|
15
|
+
"name": project.get("name", "flake8-ic"),
|
|
16
|
+
"version": project.get("version", "0.1.0"),
|
|
17
|
+
}
|
|
18
|
+
except Exception:
|
|
19
|
+
return {"name": "flake8-ic", "version": "0.1.0"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: flake8-ic
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: This package provides a plugin for flake8 that checks the usage of ic() function from icecream package.
|
|
5
|
+
Author-email: Marco Espinosa <marco@marcoespinosa.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2025 Marco Espinosa
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Keywords: code quality,debugging,flake8,ic,icecream,linting,plugin
|
|
29
|
+
Classifier: Development Status :: 3 - Alpha
|
|
30
|
+
Classifier: Environment :: Console
|
|
31
|
+
Classifier: Intended Audience :: Developers
|
|
32
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
33
|
+
Classifier: Operating System :: OS Independent
|
|
34
|
+
Classifier: Programming Language :: Python
|
|
35
|
+
Classifier: Programming Language :: Python :: 3
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
39
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
40
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
41
|
+
Classifier: Topic :: Software Development :: Testing
|
|
42
|
+
Requires-Python: >=3.11
|
|
43
|
+
Requires-Dist: flake8>=7.1.1
|
|
44
|
+
Requires-Dist: toml>=0.10.2
|
|
45
|
+
Description-Content-Type: text/markdown
|
|
46
|
+
|
|
47
|
+
<!-- Shields -->
|
|
48
|
+
<p align="center">
|
|
49
|
+
<a href="https://github.com/maekind/flake8-ic"><img src="https://img.shields.io/github/actions/workflow/status/maekind/flake8-ic/.github%2Fworkflows%2Ftesting.yaml?label=tests&color=green" hspace="5"></a>
|
|
50
|
+
<a href="https://codecov.io/gh/maekind/flake8-ic"><img src="https://codecov.io/gh/maekind/flake8-ic/graph/badge.svg?token=JcGna50uJL" hspace="5"/></a>
|
|
51
|
+
<a href="https://github.com/maekind/flake8-ic/releases"><img src="https://img.shields.io/github/actions/workflow/status/maekind/flake8-ic/.github%2Fworkflows%2Frelease.yaml?label=build package&color=green" hspace="5"></a>
|
|
52
|
+
<a href="https://pypi.org/project/flake8-ic"><img src="https://img.shields.io/github/v/release/maekind/flake8-ic?color=blue&label=pypi latest" hspace="5"></a>
|
|
53
|
+
<br>
|
|
54
|
+
<a href="https://github.com/maekind/flake8-ic/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-MIT-orange.svg" hspace="5"></a>
|
|
55
|
+
<a href="https://github.com/maekind/flake8-ic"><img src="https://img.shields.io/github/repo-size/maekind/flake8-ic?color=red" hspace="5"></a>
|
|
56
|
+
<a href="https://github.com/maekind/flake8-ic"><img src="https://img.shields.io/github/last-commit/maekind/flake8-ic?color=black" hspace="5"></a>
|
|
57
|
+
<a href="https://www.python.org/downloads/"><img src="https://img.shields.io/github/languages/top/maekind/flake8-ic?color=darkgreen" hspace="5"></a>
|
|
58
|
+
<a href="https://www.python.org/downloads/"><img src="https://img.shields.io/badge/python%20version-%3E3.11-lightblue" hspace="5"></a>
|
|
59
|
+
</p>
|
|
60
|
+
|
|
61
|
+
# flake8-ic
|
|
62
|
+
|
|
63
|
+
## Description
|
|
64
|
+
|
|
65
|
+
This package provides a plugin for `flake8` to check the usage of the `ic()` function from the `icecream` package in your codebase.
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
|
|
69
|
+
You can install this package using pip:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pip install flake8-ic
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Check installation
|
|
76
|
+
|
|
77
|
+
You can check the installation by running the following command:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
flake8 --version
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
You should see the installed version of `flake8` and the installed plugins, including `flake8-ic`.
|
|
84
|
+
|
|
85
|
+
## Contributors
|
|
86
|
+
|
|
87
|
+
<a href="https://github.com/maekind/flake8-ic/graphs/contributors">
|
|
88
|
+
<img src="https://contrib.rocks/image?repo=maekind/flake8-ic" />
|
|
89
|
+
</a>
|
|
90
|
+
<br/>
|
|
91
|
+
<br/>
|
|
92
|
+
|
|
93
|
+
(c) <a href="mailto:marco@marcoespinosa.com">Marco Espinosa</a>, 2024
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
flake8_ic/__init__.py,sha256=fF5NHoA6bi94M17PkZAdyVxE5ABIKMNk0WmXM63_gG0,77
|
|
2
|
+
flake8_ic/checker.py,sha256=HKvl7TjOxLB0FFLuuaE0LhAVL7DC_jOsyeA4A2XRKfM,1286
|
|
3
|
+
flake8_ic/metadata.py,sha256=VNbhtGjtd3x2uPvyx1Ut6PO6oSsQnS3_d7QdRO4VQ3k,555
|
|
4
|
+
flake8_ic-0.1.0.dist-info/METADATA,sha256=qrVxrD13CAlt4KR82MWGzzYXpqDtQOxlCi9BWTD10fg,4540
|
|
5
|
+
flake8_ic-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
6
|
+
flake8_ic-0.1.0.dist-info/licenses/LICENSE,sha256=seDhX1EGuAm_zNAplG3wrxZmQnDaifnwtiZSP8VSLeg,1070
|
|
7
|
+
flake8_ic-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Marco Espinosa
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|