nk-python-style 0.1.1__tar.gz → 0.2.0__tar.gz
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.
- {nk_python_style-0.1.1 → nk_python_style-0.2.0}/PKG-INFO +1 -1
- {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python/ruff.toml +1 -0
- {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python_style.egg-info/PKG-INFO +1 -1
- {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python_style.egg-info/SOURCES.txt +1 -0
- {nk_python_style-0.1.1 → nk_python_style-0.2.0}/pyproject.toml +1 -1
- nk_python_style-0.2.0/tests/test_ruff_config.py +61 -0
- {nk_python_style-0.1.1 → nk_python_style-0.2.0}/README.md +0 -0
- {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python/__init__.py +0 -0
- {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python/__main__.py +0 -0
- {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python/ast_checks.py +0 -0
- {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python/cli.py +0 -0
- {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python/comment_checks.py +0 -0
- {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python/model.py +0 -0
- {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python/ruff_runner.py +0 -0
- {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python/structure_checks.py +0 -0
- {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python_style.egg-info/dependency_links.txt +0 -0
- {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python_style.egg-info/entry_points.txt +0 -0
- {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python_style.egg-info/requires.txt +0 -0
- {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python_style.egg-info/top_level.txt +0 -0
- {nk_python_style-0.1.1 → nk_python_style-0.2.0}/setup.cfg +0 -0
- {nk_python_style-0.1.1 → nk_python_style-0.2.0}/tests/test_cli.py +0 -0
- {nk_python_style-0.1.1 → nk_python_style-0.2.0}/tests/test_rules.py +0 -0
- {nk_python_style-0.1.1 → nk_python_style-0.2.0}/tests/test_summary.py +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import subprocess
|
|
2
|
+
import sys
|
|
3
|
+
import tempfile
|
|
4
|
+
import unittest
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class RuffConfigurationTests(unittest.TestCase):
|
|
9
|
+
def check_source(self, source):
|
|
10
|
+
with tempfile.TemporaryDirectory() as temp:
|
|
11
|
+
root = Path(temp)
|
|
12
|
+
path = root / "sample.py"
|
|
13
|
+
path.write_text(source, encoding="utf-8", newline="\n")
|
|
14
|
+
checked = subprocess.run(
|
|
15
|
+
[sys.executable, "-m", "nk_python", "check", str(path)],
|
|
16
|
+
cwd=root,
|
|
17
|
+
capture_output=True,
|
|
18
|
+
text=True,
|
|
19
|
+
check=False,
|
|
20
|
+
)
|
|
21
|
+
self.assertEqual(path.read_bytes(), source.encode("utf-8"))
|
|
22
|
+
return checked.returncode, checked.stdout + checked.stderr
|
|
23
|
+
|
|
24
|
+
def test_check_ignores_only_the_disabled_rules(self):
|
|
25
|
+
source = (
|
|
26
|
+
"import warnings\n\n\n"
|
|
27
|
+
"def factory():\n return object()\n\n\n"
|
|
28
|
+
"def with_default(value=factory()):\n return value\n\n\n"
|
|
29
|
+
"def repeated():\n return 1\n\n\n"
|
|
30
|
+
"def repeated():\n return 2\n\n\n"
|
|
31
|
+
'warnings.warn("example")\n'
|
|
32
|
+
"pairs = zip([1], [2])\n"
|
|
33
|
+
)
|
|
34
|
+
status, output = self.check_source(source)
|
|
35
|
+
self.assertEqual(status, 0, output)
|
|
36
|
+
self.assertIn("All checks passed!", output)
|
|
37
|
+
for rule in ("B008", "B028", "B905", "F811"):
|
|
38
|
+
with self.subTest(rule=rule):
|
|
39
|
+
self.assertNotIn(rule, output)
|
|
40
|
+
|
|
41
|
+
def test_check_preserves_other_rules(self):
|
|
42
|
+
source = (
|
|
43
|
+
"import os\nfrom typing import List\n\n"
|
|
44
|
+
"missing_name\n"
|
|
45
|
+
"42\n"
|
|
46
|
+
"for unused in range(2):\n"
|
|
47
|
+
' print("example")\n'
|
|
48
|
+
"callbacks = []\n"
|
|
49
|
+
"for value in range(2):\n"
|
|
50
|
+
" callbacks.append(lambda: value)\n"
|
|
51
|
+
"identity = lambda value: value\n"
|
|
52
|
+
)
|
|
53
|
+
status, output = self.check_source(source)
|
|
54
|
+
self.assertEqual(status, 1, output)
|
|
55
|
+
for rule in ("F821", "B023", "F401", "B018", "B007", "UP035", "E731"):
|
|
56
|
+
with self.subTest(rule=rule):
|
|
57
|
+
self.assertRegex(output, rf": {rule}\b")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
if __name__ == "__main__":
|
|
61
|
+
unittest.main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python_style.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|