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.
Files changed (23) hide show
  1. {nk_python_style-0.1.1 → nk_python_style-0.2.0}/PKG-INFO +1 -1
  2. {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python/ruff.toml +1 -0
  3. {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python_style.egg-info/PKG-INFO +1 -1
  4. {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python_style.egg-info/SOURCES.txt +1 -0
  5. {nk_python_style-0.1.1 → nk_python_style-0.2.0}/pyproject.toml +1 -1
  6. nk_python_style-0.2.0/tests/test_ruff_config.py +61 -0
  7. {nk_python_style-0.1.1 → nk_python_style-0.2.0}/README.md +0 -0
  8. {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python/__init__.py +0 -0
  9. {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python/__main__.py +0 -0
  10. {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python/ast_checks.py +0 -0
  11. {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python/cli.py +0 -0
  12. {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python/comment_checks.py +0 -0
  13. {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python/model.py +0 -0
  14. {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python/ruff_runner.py +0 -0
  15. {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python/structure_checks.py +0 -0
  16. {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python_style.egg-info/dependency_links.txt +0 -0
  17. {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python_style.egg-info/entry_points.txt +0 -0
  18. {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python_style.egg-info/requires.txt +0 -0
  19. {nk_python_style-0.1.1 → nk_python_style-0.2.0}/nk_python_style.egg-info/top_level.txt +0 -0
  20. {nk_python_style-0.1.1 → nk_python_style-0.2.0}/setup.cfg +0 -0
  21. {nk_python_style-0.1.1 → nk_python_style-0.2.0}/tests/test_cli.py +0 -0
  22. {nk_python_style-0.1.1 → nk_python_style-0.2.0}/tests/test_rules.py +0 -0
  23. {nk_python_style-0.1.1 → nk_python_style-0.2.0}/tests/test_summary.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nk-python-style
3
- Version: 0.1.1
3
+ Version: 0.2.0
4
4
  Summary: Python formatter and linter following the repository's conventions
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -6,6 +6,7 @@ extend-exclude = [".git", ".venv*", "venv", "__pycache__", "build", "dist", "nod
6
6
 
7
7
  [lint]
8
8
  select = ["E4", "E7", "E9", "F", "I", "B", "UP", "RET504"]
9
+ ignore = ["B008", "B028", "B905", "F811"]
9
10
 
10
11
  [format]
11
12
  indent-style = "space"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nk-python-style
3
- Version: 0.1.1
3
+ Version: 0.2.0
4
4
  Summary: Python formatter and linter following the repository's conventions
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -16,5 +16,6 @@ nk_python_style.egg-info/entry_points.txt
16
16
  nk_python_style.egg-info/requires.txt
17
17
  nk_python_style.egg-info/top_level.txt
18
18
  tests/test_cli.py
19
+ tests/test_ruff_config.py
19
20
  tests/test_rules.py
20
21
  tests/test_summary.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "nk-python-style"
7
- version = "0.1.1"
7
+ version = "0.2.0"
8
8
  description = "Python formatter and linter following the repository's conventions"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -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()