nmk-python 1.1.0__py3-none-any.whl → 1.2.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.
nmk_python/ruff.py CHANGED
@@ -7,6 +7,7 @@ from pathlib import Path
7
7
 
8
8
  from nmk.model.builder import NmkTaskBuilder
9
9
  from nmk.model.keys import NmkRootConfig
10
+ from nmk.model.resolver import NmkStrConfigResolver
10
11
  from nmk.utils import run_with_logs
11
12
 
12
13
 
@@ -35,7 +36,23 @@ class RuffBuilder(NmkTaskBuilder):
35
36
  relative_src_folders.append(p)
36
37
 
37
38
  # Delegate to ruff
38
- run_with_logs(["ruff", command] + relative_src_folders, self.logger, cwd=project_folder)
39
+ run_with_logs(["ruff"] + [arg for arg in command.split(" ") if arg] + relative_src_folders, self.logger, cwd=project_folder)
39
40
 
40
41
  # Touch output file
41
42
  self.main_output.touch()
43
+
44
+
45
+ class JoinedRulesResolver(NmkStrConfigResolver):
46
+ """
47
+ Join auto-fix rules as a comma separated string
48
+ """
49
+
50
+ def get_value(self, name: str, rules: list[str]) -> str:
51
+ """
52
+ Return coma separated rules list string
53
+
54
+ :param name: name of the config
55
+ :param rules: list of rules
56
+ :return: coma separated rules list string
57
+ """
58
+ return ",".join(rules)
nmk_python/ruff.yml CHANGED
@@ -9,8 +9,23 @@ config:
9
9
 
10
10
  # Stamp files for ruff execution
11
11
  pythonRuffFormatStamp: ${outputDir}/.ruff-format
12
+ pythonRuffFixStamp: ${outputDir}/.ruff-fix
12
13
  pythonRuffCheckStamp: ${outputDir}/.ruff-check
13
14
 
15
+ # Extra arguments for ruff command lines
16
+ pythonRuffCommonExtraArgs: ""
17
+ pythonRuffFormatExtraArgs: ""
18
+ pythonRuffFixExtraArgs: ""
19
+ pythonRuffCheckExtraArgs: ""
20
+
21
+ # Auto-fix rules
22
+ pythonAutoFixRules: ["I"] # Default: only fix imports
23
+ pythonAutoFixJoinedRules:
24
+ __resolver__: nmk_python.ruff.JoinedRulesResolver
25
+ params:
26
+ rules:
27
+ - ${pythonAutoFixRules}
28
+
14
29
  # Ignored rules
15
30
  pythonIgnoredRules:
16
31
  - E203 # space before ":"; sometimes formatting with black introduces this kind of space in slice expressions
@@ -39,14 +54,32 @@ tasks:
39
54
  builder: nmk_python.ruff.RuffBuilder
40
55
  params:
41
56
  src_folders: ${pythonSrcFolders}
42
- command: format
57
+ command: format ${pythonRuffCommonExtraArgs} ${pythonRuffFormatExtraArgs}
58
+
59
+ # Python source code fix with ruff
60
+ py.fix:
61
+ description: Fix python code
62
+ emoji: ":snake:.:wrench:"
63
+ deps:
64
+ - py.format
65
+ appendToDeps: build
66
+ if: ${pythonSrcFiles} # Only if python source files are found
67
+ output:
68
+ - ${pythonRuffFixStamp}
69
+ input:
70
+ - ${pythonProjectFile}
71
+ - ${pythonSrcFiles}
72
+ builder: nmk_python.ruff.RuffBuilder
73
+ params:
74
+ src_folders: ${pythonSrcFolders}
75
+ command: check --fix-only --select ${pythonAutoFixJoinedRules} ${pythonRuffCommonExtraArgs} ${pythonRuffFixExtraArgs}
43
76
 
44
77
  # Python source code analysis with ruff
45
78
  py.analyze:
46
79
  description: Analyze python code
47
80
  emoji: ":snake:.:eye: "
48
81
  deps:
49
- - py.format
82
+ - py.fix
50
83
  appendToDeps: build
51
84
  if: ${pythonSrcFiles} # Only if python source files are found
52
85
  output:
@@ -57,4 +90,4 @@ tasks:
57
90
  builder: nmk_python.ruff.RuffBuilder
58
91
  params:
59
92
  src_folders: ${pythonSrcFolders}
60
- command: check
93
+ command: check ${pythonRuffCommonExtraArgs} ${pythonRuffCheckExtraArgs}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: nmk-python
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: Python plugin for nmk build system
5
5
  Author: The dynod project
6
6
  Maintainer: The dynod project
@@ -43,7 +43,7 @@ Python plugin for nmk build system
43
43
 
44
44
  This plugin adds support for Python development in an **`nmk`** project:
45
45
  * project file generation
46
- * code format and analysis with [ruff](https://astral.sh/ruff)
46
+ * code format, fix and analysis with [ruff](https://astral.sh/ruff)
47
47
  * python wheel build
48
48
  * test with [pytest](https://pytest.org)
49
49
  * VSCode settings generation (if [**`nmk-vscode`**](https://github.com/dynod/nmk-vscode) plugin is also used)
@@ -7,8 +7,8 @@ nmk_python/files.py,sha256=gtPf6ldR5F4oGsAdzFnEIbI9MqqvF3z5JQnyONZmLmk,1863
7
7
  nmk_python/files.yml,sha256=-vGjogdulwsfdKVEUa5RARYDKxF3m9RmHKFnIhaT3_k,780
8
8
  nmk_python/plugin.yml,sha256=hi7osXyIwpHgJAsww5mhOA6emxhzgitDF8cOsvyY29Y,1068
9
9
  nmk_python/project.yml,sha256=sRIMvKkasrYlIvOo3DsVyNM_sgID_sHVgZg_bSIqtfw,975
10
- nmk_python/ruff.py,sha256=tfqC66NEB3P1FID1qzP-Ba3hafF02A1I9GIeruGUW2U,1058
11
- nmk_python/ruff.yml,sha256=09ackKHfT9oXKqIniYUehFkyW2DUxlHl5Ak5x2tlvQQ,1808
10
+ nmk_python/ruff.py,sha256=TBmn5nFflcFRvjj36JtJGJ-GYHOK6XfhK9Jp-2dO5_E,1557
11
+ nmk_python/ruff.yml,sha256=FNmYjbv2l5vlqFXinY87LfgzpZ3PSiduB_xUiYw8aMw,3019
12
12
  nmk_python/tests.py,sha256=8kRKP3dT2Thi5W5sCQSQOPXkV1D9C7tde3QYySo6G2c,1212
13
13
  nmk_python/tests.yml,sha256=wQusYK1bxSl87zWFQy5lJcrkcAz4pMEZT9Vt6o2K5Vs,1538
14
14
  nmk_python/version.py,sha256=fLpOWdujYwlJB7XhWaOGCTeg3gQaClk2YHoRkkW64dE,3109
@@ -19,8 +19,8 @@ nmk_python/templates/pytest.toml.jinja,sha256=zQ3SRWnF23Omxm7zInE54j0l3OyjXSOn5p
19
19
  nmk_python/templates/python-settings.json.jinja,sha256=-6J1tybWEzChxlDqu4tp9BMWxbYD8HpztGs9G8LkC_w,877
20
20
  nmk_python/templates/python-test-debug-launch.json.jinja,sha256=J_xju2EpHNXvgvqBxlf99p7g-ZMh3xE-_2r7o_57gpU,364
21
21
  nmk_python/templates/ruff.toml.jinja,sha256=DTHe1ixK1SBY8d2xBCfkGz89HzjAoMO7Ogs12AY1i4Y,346
22
- nmk_python-1.1.0.dist-info/LICENSE,sha256=PROo9EW7wP6jmSr_90OluItAsIB411b_CAqEBioMKpI,1074
23
- nmk_python-1.1.0.dist-info/METADATA,sha256=xdcI0iJEVV_3VQQHdj2m0oEo5ith5CAhcSMQSXM2CWo,3118
24
- nmk_python-1.1.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
25
- nmk_python-1.1.0.dist-info/top_level.txt,sha256=MCb5w_hoOZ0kk3Dajxrd9Pz6lZ3pyuS6TQCRA3vddTo,11
26
- nmk_python-1.1.0.dist-info/RECORD,,
22
+ nmk_python-1.2.0.dist-info/LICENSE,sha256=PROo9EW7wP6jmSr_90OluItAsIB411b_CAqEBioMKpI,1074
23
+ nmk_python-1.2.0.dist-info/METADATA,sha256=jg5UEZbY9-uyEvCIH1PF3x2sqmFkPAxR5DsUejU5epQ,3123
24
+ nmk_python-1.2.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
25
+ nmk_python-1.2.0.dist-info/top_level.txt,sha256=MCb5w_hoOZ0kk3Dajxrd9Pz6lZ3pyuS6TQCRA3vddTo,11
26
+ nmk_python-1.2.0.dist-info/RECORD,,