wexample-wex-addon-dev-python 0.0.36__py3-none-any.whl → 0.0.38__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.
@@ -32,11 +32,13 @@ def _code_check_mypy(kernel: "Kernel", file_path: str) -> bool:
32
32
  source = BuildSource(path=file_path, module=None, text=None)
33
33
  result = build.build(sources=[source], options=options, alt_lib_path=None)
34
34
  if result.errors:
35
- kernel.io.error(f"Mypy found errors in {file_path}:")
35
+ kernel.io.log_indent_up()
36
+ kernel.io.error(f"Mypy errors:")
36
37
  kernel.io.log_indent_up()
37
38
 
38
39
  for error in result.errors:
39
40
  kernel.io.error(message=error, symbol=False)
40
- kernel.io.log_indent_down()
41
+
42
+ kernel.io.log_indent_down(number=2)
41
43
  return False
42
44
  return True
@@ -1,7 +1,10 @@
1
- from wexample_wex_core.common.kernel import Kernel
1
+ from typing import TYPE_CHECKING
2
2
 
3
+ if TYPE_CHECKING:
4
+ from wexample_wex_core.common.execution_context import ExecutionContext
3
5
 
4
- def _code_check_pylint(kernel: "Kernel", file_path: str) -> bool:
6
+
7
+ def _code_check_pylint(context: "ExecutionContext", file_path: str) -> bool:
5
8
  """Check a Python file using pylint for code quality.
6
9
 
7
10
  Args:
@@ -11,7 +14,6 @@ def _code_check_pylint(kernel: "Kernel", file_path: str) -> bool:
11
14
  Returns:
12
15
  bool: True if check passes, False otherwise
13
16
  """
14
- # Import pylint modules
15
17
  import json
16
18
  import subprocess
17
19
  import sys
@@ -43,7 +45,7 @@ def _code_check_pylint(kernel: "Kernel", file_path: str) -> bool:
43
45
 
44
46
  # If no output or invalid JSON, return empty list
45
47
  if not json_output:
46
- kernel.io.success(f"No pylint issues found in {file_path}")
48
+ context.io.success(f"No pylint issues found in {file_path}")
47
49
  return True
48
50
 
49
51
  # Parse the JSON output
@@ -60,37 +62,41 @@ def _code_check_pylint(kernel: "Kernel", file_path: str) -> bool:
60
62
  if errors or warnings or conventions:
61
63
  # Display errors
62
64
  if errors:
63
- kernel.io.error(f"Pylint found errors in {file_path}:")
64
- kernel.io.log_indent_up()
65
+ context.io.log_indent_up()
66
+ context.io.error(f"Pylint errors:")
67
+ context.io.log_indent_up()
68
+
65
69
  for error in errors:
66
- kernel.io.error(
70
+ context.io.error(
67
71
  message=f"Line {error.get('line')}: "
68
- f"{error.get('message')} ({error.get('symbol')})",
72
+ f"{error.get('message')} ({error.get('symbol')})",
69
73
  symbol=False,
70
74
  )
71
- kernel.io.log_indent_down()
75
+
76
+ context.io.log_indent_down(number=2)
72
77
 
73
78
  # Display warnings with detailed logging
74
79
  if warnings:
75
- kernel.io.warning(f"Pylint found warnings in {file_path}:")
76
- kernel.io.log_indent_up()
80
+ context.io.log_indent_up()
81
+ context.io.warning(f"Pylint warnings:")
82
+ context.io.log_indent_up()
77
83
 
78
84
  for warning in warnings:
79
- kernel.io.warning(
85
+ context.io.warning(
80
86
  f"Line {warning.get('line')}: "
81
87
  f"{warning.get('message')} ({warning.get('symbol')})",
82
88
  symbol=False,
83
89
  )
84
- kernel.io.properties(warning)
90
+ context.io.properties(warning)
85
91
 
86
- kernel.io.log_indent_down()
92
+ context.io.log_indent_down(number=2)
87
93
  # Display conventions
88
94
  if conventions:
89
- kernel.io.info("Conventions:")
95
+ context.io.info("Conventions:")
90
96
  for convention in conventions:
91
- kernel.io.base(
97
+ context.io.base(
92
98
  message=f" Line {convention.get('line')}: "
93
- f"{convention.get('message')} ({convention.get('symbol')})"
99
+ f"{convention.get('message')} ({convention.get('symbol')})"
94
100
  )
95
101
 
96
102
  # Only consider errors as failures
@@ -49,8 +49,8 @@ def _code_check_pyright(kernel: "Kernel", file_path: str) -> bool:
49
49
  if errors or warnings or info:
50
50
  # Display errors
51
51
  if errors:
52
- kernel.io.error(f"Pyright found errors in {file_path}:")
53
52
  kernel.io.log_indent_up()
53
+ kernel.io.error(f"Pyright errors:")
54
54
 
55
55
  for error in errors:
56
56
  line = error.get("range", {}).get("start", {}).get("line", 0) + 1
@@ -60,12 +60,12 @@ def _code_check_pyright(kernel: "Kernel", file_path: str) -> bool:
60
60
  kernel.io.error(f"Line {line}: {message}{rule_text}", symbol=False)
61
61
  kernel.io.properties(error)
62
62
 
63
- kernel.io.log_indent_down()
63
+ kernel.io.log_indent_down(number=2)
64
64
 
65
65
  # Display warnings
66
66
  if warnings:
67
- kernel.io.warning(f"Pyright found warnings in {file_path}:")
68
67
  kernel.io.log_indent_up()
68
+ kernel.io.warning(f"Pyright warnings:")
69
69
 
70
70
  for warning in warnings:
71
71
  line = warning.get("range", {}).get("start", {}).get("line", 0) + 1
@@ -75,11 +75,12 @@ def _code_check_pyright(kernel: "Kernel", file_path: str) -> bool:
75
75
  kernel.io.warning(f"Line {line}: {message}{rule_text}", symbol=False)
76
76
  kernel.io.properties(warning)
77
77
 
78
- kernel.io.log_indent_down()
78
+ kernel.io.log_indent_down(number=2)
79
79
 
80
80
  # Display information
81
81
  if info:
82
- kernel.io.info(f"Pyright found information in {file_path}:")
82
+ kernel.io.log_indent_up()
83
+ kernel.io.info(f"Pyright information:")
83
84
  kernel.io.log_indent_up()
84
85
 
85
86
  for item in info:
@@ -90,7 +91,7 @@ def _code_check_pyright(kernel: "Kernel", file_path: str) -> bool:
90
91
  kernel.io.info(f"Line {line}: {message}{rule_text}", symbol=False)
91
92
  kernel.io.properties(item)
92
93
 
93
- kernel.io.log_indent_down()
94
+ kernel.io.log_indent_down(number=2)
94
95
 
95
96
  # Only consider errors as failures
96
97
  if errors:
@@ -1,54 +1,49 @@
1
- from typing import Optional
1
+ from typing import Optional, TYPE_CHECKING
2
2
 
3
- from wexample_wex_core.common.kernel import Kernel
3
+ from wexample_wex_core.const.middleware import MIDDLEWARE_OPTION_VALUE_OPTIONAL, MIDDLEWARE_OPTION_VALUE_ALLWAYS
4
4
  from wexample_wex_core.decorator.command import command
5
5
  from wexample_wex_core.decorator.middleware import middleware
6
6
  from wexample_wex_core.decorator.option import option
7
+ from wexample_wex_core.decorator.option_stop_on_failure import option_stop_on_failure
7
8
 
9
+ if TYPE_CHECKING:
10
+ from wexample_wex_core.common.execution_context import ExecutionContext
8
11
 
12
+
13
+ # TODO working command: bash cli/wex python::code/check --file ../../pip/wex-core/wexample_wex_core/ -sof
9
14
  @option(
10
15
  name="tool",
11
16
  type=str,
12
17
  required=False,
13
18
  description="Specific tool to run (mypy, pylint, pyright). If not specified, all tools will be run.",
14
19
  )
15
- @option(
16
- name="stop_on_failure",
17
- type=bool,
18
- required=False,
19
- default=True,
20
- description="Stop execution when a tool reports a failure",
21
- )
20
+ @option_stop_on_failure()
22
21
  @middleware(
23
- # TODO working command: bash cli/wex python::code/check --file ../../pip/wex-core/wexample_wex_core/ -sof
24
- # -> sof / stop_on_failure does not works
25
- # en tout cas ça ne marche pas lors de l'itération, il faudrait etre capable d'ajouter un signal d'arret.
26
- # -> Gérer les valeurs de retour, pour l'instant c'est une liste, ce sera un MultipleResponse
27
- # -> continue_on_error=False,
28
- # -> aggregation_mode='list',
29
- # -> parallel=True,
30
- # -> limit=False,
31
- # -> show_progres=True
32
- # -> Peut être que
33
22
  name="each_python_file",
34
23
  should_exist=True,
35
24
  expand_glob=True,
36
- recursive=True)
37
- # TODO après et durant la mise en place de ça on pourrait:
25
+ stop_on_failure=MIDDLEWARE_OPTION_VALUE_OPTIONAL,
26
+ recursive=True,
27
+ parallel=MIDDLEWARE_OPTION_VALUE_OPTIONAL,
28
+ show_progress=MIDDLEWARE_OPTION_VALUE_ALLWAYS
29
+ )
30
+ # TODO
38
31
  # - Créer des commandes de test
39
- # - Les outilis utilisent des méthodes pour exécuter des commandes shell, on peut les wrap dans des premier helpers
32
+ # - Les outils utilisent des méthodes pour exécuter des commandes shell, on peut les wrap dans des premier helpers
40
33
  # - Dans les commandes de test:
41
34
  # > teste l'appel de commandes en interne
42
35
  # > teste du prompting et des context de prompt et du nesting
43
36
  @command()
44
37
  def python__code__check(
45
- kernel: "Kernel",
46
- file: str,
47
- tool: Optional[str] = None,
48
- stop_on_failure: bool = True,
38
+ context: "ExecutionContext",
39
+ file: str,
40
+ tool: Optional[str] = None,
41
+ stop_on_failure: bool = True,
42
+ parallel: bool = True,
49
43
  ) -> bool:
50
44
  """Check a Python file using various code quality tools."""
51
45
  from wexample_wex_addon_dev_python.commands.code.check.mypy import _code_check_mypy
46
+ from wexample_helpers.helpers.cli import cli_make_clickable_path
52
47
  from wexample_wex_addon_dev_python.commands.code.check.pylint import (
53
48
  _code_check_pylint,
54
49
  )
@@ -80,22 +75,29 @@ def python__code__check(
80
75
 
81
76
  # Run each check function
82
77
  for check_function in check_functions:
83
- kernel.io.title(check_function.__name__)
84
- kernel.io.log_indent_up()
85
- kernel.io.log(file)
78
+ context.io.title(check_function.__name__)
79
+ context.io.log_indent_up()
80
+
81
+ context.io.log(
82
+ f'🐍 Python: {cli_make_clickable_path(context.kernel.host_workdir.get_resolved_target(file))}'
83
+ )
86
84
 
87
- check_result = check_function(kernel, file)
85
+ check_result = check_function(context, file)
88
86
 
89
87
  if check_result:
90
- kernel.io.success(f"No critical issue found for {check_function.__name__}")
88
+ context.io.success(f"No critical issue found for {check_function.__name__}")
91
89
 
92
90
  # Update overall success status
93
91
  all_checks_passed = all_checks_passed and check_result
94
- kernel.io.log_indent_down()
95
92
 
96
93
  # Stop if a check fails and stop_on_failure is True
97
94
  if not check_result and stop_on_failure:
98
- kernel.io.error("One check failed")
99
- return False
95
+ context.io.error("One check failed")
96
+
97
+ from wexample_app.response.failure_response import FailureResponse
98
+ context.io.log_indent_down()
99
+
100
+ return FailureResponse(message="One check failed", kernel=context.kernel)
100
101
 
102
+ context.io.log_indent_down()
101
103
  return all_checks_passed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wexample-wex-addon-dev-python
3
- Version: 0.0.36
3
+ Version: 0.0.38
4
4
  Summary: Python dev addon for wex
5
5
  Author-email: weeger <contact@wexample.com>
6
6
  License: MIT
@@ -1,17 +1,17 @@
1
1
  wexample_wex_addon_dev_python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  wexample_wex_addon_dev_python/python_addon_manager.py,sha256=iEgJ-jqrReMMkI2tHIOSKlumKXBW1ZAbGTzXY17Ilh0,497
3
- wexample_wex_addon_dev_python/commands/code/check.py,sha256=dPc_F43hZashUbBmx8dgcLsecpGJdTEWSZv-dwh8kNM,3498
3
+ wexample_wex_addon_dev_python/commands/code/check.py,sha256=f_cTeGVAiLJCjTe-lOa74ynOrhtkDOJFwtW4sdj_J6Q,3682
4
4
  wexample_wex_addon_dev_python/commands/code/format.py,sha256=r2DNT6_Mf9ltKRY7beqBCHIXmXn6LWe8h0Jm7TAX0xs,2395
5
5
  wexample_wex_addon_dev_python/commands/code/check/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- wexample_wex_addon_dev_python/commands/code/check/mypy.py,sha256=gYuNb_8KHJfVnkh8ZVVIOkwi6wzxYYSyhrkzjnphL7o,1315
7
- wexample_wex_addon_dev_python/commands/code/check/pylint.py,sha256=FOQrEsLKLKBiOYN2-05DdM4a47V-kNrmjdAVSxyqOzY,3167
8
- wexample_wex_addon_dev_python/commands/code/check/pyright.py,sha256=4ZqVAP-Vbld03E0WbI6Cvqxam2iGQDJvhxwbMdoDU-M,3530
6
+ wexample_wex_addon_dev_python/commands/code/check/mypy.py,sha256=2Dy72ctj6RFaL4uMQTyWKAJePhULqu9AMfOli8DYF4w,1337
7
+ wexample_wex_addon_dev_python/commands/code/check/pylint.py,sha256=HmGUfJQWlVcmFrPHwwTimfegUAdmIJvga5_lfl8i258,3309
8
+ wexample_wex_addon_dev_python/commands/code/check/pyright.py,sha256=22a8bOBrVSZzSTJRggGx1smgT9ZsnxbIy4EpJdvBLZg,3529
9
9
  wexample_wex_addon_dev_python/commands/code/format/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
10
10
  wexample_wex_addon_dev_python/commands/code/format/black.py,sha256=qDr_siZYzSDoCv1BIqa95S0C97cW7mp7kWLxidJvP4s,1372
11
11
  wexample_wex_addon_dev_python/commands/code/format/isort.py,sha256=IwBeUntdtUwbmvW2OMDwVSjmxrPCPu2BOuZ_8RAnFC8,1450
12
12
  wexample_wex_addon_dev_python/middleware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  wexample_wex_addon_dev_python/middleware/each_python_file_middleware.py,sha256=K9thNgehAKN3WDvOCfa_k9pfPGZi_ooay7m9ttWOhK8,2317
14
- wexample_wex_addon_dev_python-0.0.36.dist-info/METADATA,sha256=7Ut3UFGcCF4r53KGH0yxfBy3h2Dbh6Ayq-Bomjb1W9o,471
15
- wexample_wex_addon_dev_python-0.0.36.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
- wexample_wex_addon_dev_python-0.0.36.dist-info/top_level.txt,sha256=UH2tJu4bqlyH4nrhg8KctBXufm1rw1ZprTwvdz0robs,30
17
- wexample_wex_addon_dev_python-0.0.36.dist-info/RECORD,,
14
+ wexample_wex_addon_dev_python-0.0.38.dist-info/METADATA,sha256=iQWzY7Dh9exhdDZE_AjcLeaNIDxlTRJTLxz6dm4ZEfI,471
15
+ wexample_wex_addon_dev_python-0.0.38.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
+ wexample_wex_addon_dev_python-0.0.38.dist-info/top_level.txt,sha256=UH2tJu4bqlyH4nrhg8KctBXufm1rw1ZprTwvdz0robs,30
17
+ wexample_wex_addon_dev_python-0.0.38.dist-info/RECORD,,