wexample-wex-addon-dev-python 0.0.33__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 (21) hide show
  1. wexample_wex_addon_dev_python-0.0.33/PKG-INFO +14 -0
  2. wexample_wex_addon_dev_python-0.0.33/README.md +1 -0
  3. wexample_wex_addon_dev_python-0.0.33/pyproject.toml +31 -0
  4. wexample_wex_addon_dev_python-0.0.33/setup.cfg +4 -0
  5. wexample_wex_addon_dev_python-0.0.33/wexample_wex_addon_dev_python/__init__.py +0 -0
  6. wexample_wex_addon_dev_python-0.0.33/wexample_wex_addon_dev_python/commands/code/check/__init__.py +0 -0
  7. wexample_wex_addon_dev_python-0.0.33/wexample_wex_addon_dev_python/commands/code/check/mypy.py +42 -0
  8. wexample_wex_addon_dev_python-0.0.33/wexample_wex_addon_dev_python/commands/code/check/pylint.py +100 -0
  9. wexample_wex_addon_dev_python-0.0.33/wexample_wex_addon_dev_python/commands/code/check/pyright.py +98 -0
  10. wexample_wex_addon_dev_python-0.0.33/wexample_wex_addon_dev_python/commands/code/check.py +101 -0
  11. wexample_wex_addon_dev_python-0.0.33/wexample_wex_addon_dev_python/commands/code/format/__init__.py +1 -0
  12. wexample_wex_addon_dev_python-0.0.33/wexample_wex_addon_dev_python/commands/code/format/black.py +41 -0
  13. wexample_wex_addon_dev_python-0.0.33/wexample_wex_addon_dev_python/commands/code/format/isort.py +42 -0
  14. wexample_wex_addon_dev_python-0.0.33/wexample_wex_addon_dev_python/commands/code/format.py +75 -0
  15. wexample_wex_addon_dev_python-0.0.33/wexample_wex_addon_dev_python/middleware/__init__.py +0 -0
  16. wexample_wex_addon_dev_python-0.0.33/wexample_wex_addon_dev_python/middleware/each_python_file_middleware.py +74 -0
  17. wexample_wex_addon_dev_python-0.0.33/wexample_wex_addon_dev_python/python_addon_manager.py +13 -0
  18. wexample_wex_addon_dev_python-0.0.33/wexample_wex_addon_dev_python.egg-info/PKG-INFO +14 -0
  19. wexample_wex_addon_dev_python-0.0.33/wexample_wex_addon_dev_python.egg-info/SOURCES.txt +19 -0
  20. wexample_wex_addon_dev_python-0.0.33/wexample_wex_addon_dev_python.egg-info/dependency_links.txt +1 -0
  21. wexample_wex_addon_dev_python-0.0.33/wexample_wex_addon_dev_python.egg-info/top_level.txt +1 -0
@@ -0,0 +1,14 @@
1
+ Metadata-Version: 2.4
2
+ Name: wexample-wex-addon-dev-python
3
+ Version: 0.0.33
4
+ Summary: Python dev addon for wex
5
+ Author-email: weeger <contact@wexample.com>
6
+ License: MIT
7
+ Project-URL: homepage, https://github.com/wexample/python-wex-dev-python
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.6
12
+ Description-Content-Type: text/markdown
13
+
14
+ # Wex Addon Dev Python
@@ -0,0 +1 @@
1
+ # Wex Addon Dev Python
@@ -0,0 +1,31 @@
1
+ [build-system]
2
+ requires = [
3
+ "setuptools",
4
+ "wheel",
5
+ ]
6
+ build-backend = "setuptools.build_meta"
7
+
8
+ [project]
9
+ name = "wexample-wex-addon-dev-python"
10
+ version = "0.0.33"
11
+ description = "Python dev addon for wex"
12
+ authors = [
13
+ { name = "weeger", email = "contact@wexample.com" },
14
+ ]
15
+ requires-python = ">=3.6"
16
+ classifiers = [
17
+ "Programming Language :: Python :: 3",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: OS Independent",
20
+ ]
21
+ dependencies = []
22
+
23
+ [project.readme]
24
+ file = "README.md"
25
+ content-type = "text/markdown"
26
+
27
+ [project.license]
28
+ text = "MIT"
29
+
30
+ [project.urls]
31
+ homepage = "https://github.com/wexample/python-wex-dev-python"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,42 @@
1
+ from wexample_wex_core.common.kernel import Kernel
2
+
3
+
4
+ def _code_check_mypy(kernel: "Kernel", file_path: str) -> bool:
5
+ """Check a Python file using mypy for static type checking.
6
+
7
+ Args:
8
+ kernel: The application kernel
9
+ file_path: Path to the Python file to check
10
+
11
+ Returns:
12
+ bool: True if check passes, False otherwise
13
+ """
14
+ import sys
15
+
16
+ # Import mypy modules
17
+ from mypy import build
18
+ from mypy.modulefinder import BuildSource
19
+ from mypy.options import Options
20
+
21
+ # Configure mypy options
22
+ options = Options()
23
+ options.python_version = sys.version_info[:2]
24
+ options.show_traceback = True
25
+ options.disallow_untyped_defs = True
26
+ options.disallow_incomplete_defs = True
27
+
28
+ # Ignore import as file might be placed anywhere, we have no more context.
29
+ options.ignore_missing_imports = True
30
+
31
+ # Build and check the file
32
+ source = BuildSource(path=file_path, module=None, text=None)
33
+ result = build.build(sources=[source], options=options, alt_lib_path=None)
34
+ if result.errors:
35
+ kernel.io.error(f"Mypy found errors in {file_path}:")
36
+ kernel.io.log_indent_up()
37
+
38
+ for error in result.errors:
39
+ kernel.io.error(message=error, symbol=False)
40
+ kernel.io.log_indent_down()
41
+ return False
42
+ return True
@@ -0,0 +1,100 @@
1
+ from wexample_wex_core.common.kernel import Kernel
2
+
3
+
4
+ def _code_check_pylint(kernel: "Kernel", file_path: str) -> bool:
5
+ """Check a Python file using pylint for code quality.
6
+
7
+ Args:
8
+ kernel: The application kernel
9
+ file_path: Path to the Python file to check
10
+
11
+ Returns:
12
+ bool: True if check passes, False otherwise
13
+ """
14
+ # Import pylint modules
15
+ import json
16
+ import subprocess
17
+ import sys
18
+
19
+ # Use subprocess to capture pylint output
20
+ # This avoids issues with pylint's direct printing to stdout
21
+ # List of warnings to disable
22
+ disabled_warnings = [
23
+ "missing-module-docstring",
24
+ "import-outside-toplevel",
25
+ "no-name-in-module",
26
+ "broad-exception-caught",
27
+ "c-extension-no-member",
28
+ "line-too-long",
29
+ ]
30
+
31
+ cmd = [
32
+ sys.executable,
33
+ "-m",
34
+ "pylint",
35
+ file_path,
36
+ "--output-format=json",
37
+ f"--disable={','.join(disabled_warnings)}",
38
+ ]
39
+ process = subprocess.run(cmd, capture_output=True, text=True, check=False)
40
+
41
+ # Get the output from stdout
42
+ json_output = process.stdout.strip()
43
+
44
+ # If no output or invalid JSON, return empty list
45
+ if not json_output:
46
+ kernel.io.success(f"No pylint issues found in {file_path}")
47
+ return True
48
+
49
+ # Parse the JSON output
50
+ results = json.loads(json_output)
51
+
52
+ # Filter messages by type
53
+ errors = [msg for msg in results if msg.get("type") in ("error", "fatal")]
54
+ warnings = [msg for msg in results if msg.get("type") == "warning"]
55
+ conventions = [
56
+ msg for msg in results if msg.get("type") in ("convention", "refactor", "info")
57
+ ]
58
+
59
+ # Display results if any issues found
60
+ if errors or warnings or conventions:
61
+ # Display errors
62
+ if errors:
63
+ kernel.io.error(f"Pylint found errors in {file_path}:")
64
+ kernel.io.log_indent_up()
65
+ for error in errors:
66
+ kernel.io.error(
67
+ message=f"Line {error.get('line')}: "
68
+ f"{error.get('message')} ({error.get('symbol')})",
69
+ symbol=False,
70
+ )
71
+ kernel.io.log_indent_down()
72
+
73
+ # Display warnings with detailed logging
74
+ if warnings:
75
+ kernel.io.warning(f"Pylint found warnings in {file_path}:")
76
+ kernel.io.log_indent_up()
77
+
78
+ for warning in warnings:
79
+ kernel.io.warning(
80
+ f"Line {warning.get('line')}: "
81
+ f"{warning.get('message')} ({warning.get('symbol')})",
82
+ symbol=False,
83
+ )
84
+ kernel.io.properties(warning)
85
+
86
+ kernel.io.log_indent_down()
87
+ # Display conventions
88
+ if conventions:
89
+ kernel.io.info("Conventions:")
90
+ for convention in conventions:
91
+ kernel.io.base(
92
+ message=f" Line {convention.get('line')}: "
93
+ f"{convention.get('message')} ({convention.get('symbol')})"
94
+ )
95
+
96
+ # Only consider errors as failures
97
+ if errors:
98
+ return False
99
+ return True
100
+ return True
@@ -0,0 +1,98 @@
1
+ from wexample_wex_core.common.kernel import Kernel
2
+
3
+
4
+ def _code_check_pyright(kernel: "Kernel", file_path: str) -> bool:
5
+ """Check a Python file using pyright for static type checking.
6
+
7
+ Args:
8
+ kernel: The application kernel
9
+ file_path: Path to the Python file to check
10
+
11
+ Returns:
12
+ bool: True if check passes, False otherwise
13
+ """
14
+ import json
15
+ import subprocess
16
+ import sys
17
+
18
+ # Use subprocess to run pyright
19
+ cmd = [sys.executable, "-m", "pyright", file_path, "--outputjson"]
20
+ process = subprocess.run(cmd, capture_output=True, text=True, check=False)
21
+
22
+ # Get the output from stdout
23
+ json_output = process.stdout.strip()
24
+
25
+ # If command failed or no output, handle the error
26
+ if process.returncode != 0 and not json_output:
27
+ kernel.io.error(f"Pyright failed to run on {file_path}")
28
+ if process.stderr:
29
+ kernel.io.error(f"Error: {process.stderr}")
30
+ return False
31
+
32
+ # If no output, assume success
33
+ if not json_output:
34
+ kernel.io.success(f"No pyright issues found in {file_path}")
35
+ return True
36
+
37
+ # Parse the JSON output
38
+ results = json.loads(json_output)
39
+
40
+ # Extract diagnostics
41
+ diagnostics = results.get("diagnostics", [])
42
+
43
+ # Filter by severity
44
+ errors = [diag for diag in diagnostics if diag.get("severity") == "error"]
45
+ warnings = [diag for diag in diagnostics if diag.get("severity") == "warning"]
46
+ info = [diag for diag in diagnostics if diag.get("severity") == "information"]
47
+
48
+ # Display results if any issues found
49
+ if errors or warnings or info:
50
+ # Display errors
51
+ if errors:
52
+ kernel.io.error(f"Pyright found errors in {file_path}:")
53
+ kernel.io.log_indent_up()
54
+
55
+ for error in errors:
56
+ line = error.get("range", {}).get("start", {}).get("line", 0) + 1
57
+ message = error.get("message", "Unknown error")
58
+ rule = error.get("rule", "")
59
+ rule_text = f" ({rule})" if rule else ""
60
+ kernel.io.error(f"Line {line}: {message}{rule_text}", symbol=False)
61
+ kernel.io.properties(error)
62
+
63
+ kernel.io.log_indent_down()
64
+
65
+ # Display warnings
66
+ if warnings:
67
+ kernel.io.warning(f"Pyright found warnings in {file_path}:")
68
+ kernel.io.log_indent_up()
69
+
70
+ for warning in warnings:
71
+ line = warning.get("range", {}).get("start", {}).get("line", 0) + 1
72
+ message = warning.get("message", "Unknown warning")
73
+ rule = warning.get("rule", "")
74
+ rule_text = f" ({rule})" if rule else ""
75
+ kernel.io.warning(f"Line {line}: {message}{rule_text}", symbol=False)
76
+ kernel.io.properties(warning)
77
+
78
+ kernel.io.log_indent_down()
79
+
80
+ # Display information
81
+ if info:
82
+ kernel.io.info(f"Pyright found information in {file_path}:")
83
+ kernel.io.log_indent_up()
84
+
85
+ for item in info:
86
+ line = item.get("range", {}).get("start", {}).get("line", 0) + 1
87
+ message = item.get("message", "Unknown info")
88
+ rule = item.get("rule", "")
89
+ rule_text = f" ({rule})" if rule else ""
90
+ kernel.io.info(f"Line {line}: {message}{rule_text}", symbol=False)
91
+ kernel.io.properties(item)
92
+
93
+ kernel.io.log_indent_down()
94
+
95
+ # Only consider errors as failures
96
+ if errors:
97
+ return False
98
+ return True
@@ -0,0 +1,101 @@
1
+ from typing import Optional
2
+
3
+ from wexample_wex_core.common.kernel import Kernel
4
+ from wexample_wex_core.decorator.command import command
5
+ from wexample_wex_core.decorator.middleware import middleware
6
+ from wexample_wex_core.decorator.option import option
7
+
8
+
9
+ @option(
10
+ name="tool",
11
+ type=str,
12
+ required=False,
13
+ description="Specific tool to run (mypy, pylint, pyright). If not specified, all tools will be run.",
14
+ )
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
+ )
22
+ @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
+ name="each_python_file",
34
+ should_exist=True,
35
+ expand_glob=True,
36
+ recursive=True)
37
+ # TODO après et durant la mise en place de ça on pourrait:
38
+ # - 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
40
+ # - Dans les commandes de test:
41
+ # > teste l'appel de commandes en interne
42
+ # > teste du prompting et des context de prompt et du nesting
43
+ @command()
44
+ def python__code__check(
45
+ kernel: "Kernel",
46
+ file: str,
47
+ tool: Optional[str] = None,
48
+ stop_on_failure: bool = True,
49
+ ) -> bool:
50
+ """Check a Python file using various code quality tools."""
51
+ from wexample_wex_addon_dev_python.commands.code.check.mypy import _code_check_mypy
52
+ from wexample_wex_addon_dev_python.commands.code.check.pylint import (
53
+ _code_check_pylint,
54
+ )
55
+ from wexample_wex_addon_dev_python.commands.code.check.pyright import (
56
+ _code_check_pyright,
57
+ )
58
+
59
+ # Map tool names to their check functions
60
+ tool_map = {
61
+ "mypy": _code_check_mypy,
62
+ "pylint": _code_check_pylint,
63
+ "pyright": _code_check_pyright,
64
+ }
65
+
66
+ # Determine which tools to run
67
+ if tool and tool.lower() in tool_map:
68
+ # Run only the specified tool
69
+ check_functions = [tool_map[tool.lower()]]
70
+ else:
71
+ # Run all tools if no specific tool is specified or if the specified tool is invalid
72
+ check_functions = [
73
+ _code_check_mypy,
74
+ _code_check_pylint,
75
+ _code_check_pyright,
76
+ ]
77
+
78
+ # Track overall success
79
+ all_checks_passed = True
80
+
81
+ # Run each check function
82
+ for check_function in check_functions:
83
+ kernel.io.title(check_function.__name__)
84
+ kernel.io.log_indent_up()
85
+ kernel.io.log(file)
86
+
87
+ check_result = check_function(kernel, file)
88
+
89
+ if check_result:
90
+ kernel.io.success(f"No critical issue found for {check_function.__name__}")
91
+
92
+ # Update overall success status
93
+ all_checks_passed = all_checks_passed and check_result
94
+ kernel.io.log_indent_down()
95
+
96
+ # Stop if a check fails and stop_on_failure is True
97
+ if not check_result and stop_on_failure:
98
+ kernel.io.error("One check failed")
99
+ return False
100
+
101
+ return all_checks_passed
@@ -0,0 +1,41 @@
1
+ from wexample_wex_core.common.kernel import Kernel
2
+
3
+
4
+ def _code_format_black(kernel: "Kernel", file_path: str) -> bool:
5
+ """Format a Python file using Black.
6
+
7
+ Args:
8
+ kernel: The application kernel
9
+ file_path: Path to the Python file to format
10
+
11
+ Returns:
12
+ bool: True if formatting succeeds, False otherwise
13
+ """
14
+ import subprocess
15
+ import sys
16
+
17
+ # Use subprocess to run black
18
+ cmd = [sys.executable, "-m", "black", file_path]
19
+ process = subprocess.run(cmd, capture_output=True, text=True, check=False)
20
+
21
+ # Check if the command was successful
22
+ if process.returncode == 0:
23
+ if "reformatted" in process.stderr or "reformatted" in process.stdout:
24
+ kernel.io.success(f"Black successfully reformatted {file_path}")
25
+ else:
26
+ kernel.io.success(f"Black: {file_path} already well formatted")
27
+ return True
28
+ else:
29
+ kernel.io.error(f"Black failed to format {file_path}")
30
+ kernel.io.log_indent_up()
31
+
32
+ if process.stderr:
33
+ kernel.io.error(f"Error: {process.stderr}", symbol=False)
34
+ if process.stdout:
35
+ kernel.io.error(f"Output: {process.stdout}", symbol=False)
36
+
37
+ # Add detailed error properties
38
+ kernel.io.properties({"returncode": process.returncode, "command": cmd})
39
+
40
+ kernel.io.log_indent_down()
41
+ return False
@@ -0,0 +1,42 @@
1
+ from wexample_wex_core.common.kernel import Kernel
2
+
3
+
4
+ def _code_format_isort(kernel: "Kernel", file_path: str) -> bool:
5
+ """Format imports in a Python file using isort.
6
+
7
+ Args:
8
+ kernel: The application kernel
9
+ file_path: Path to the Python file to format
10
+
11
+ Returns:
12
+ bool: True if formatting succeeds, False otherwise
13
+ """
14
+ import subprocess
15
+ import sys
16
+
17
+ # Use subprocess to run isort
18
+ # --profile=black ensures compatibility with Black formatter
19
+ cmd = [sys.executable, "-m", "isort", "--profile=black", file_path]
20
+ process = subprocess.run(cmd, capture_output=True, text=True, check=False)
21
+
22
+ # Check if the command was successful
23
+ if process.returncode == 0:
24
+ if "Skipped" in process.stdout:
25
+ kernel.io.success(f"isort: {file_path} already well formatted")
26
+ else:
27
+ kernel.io.success(f"isort successfully reformatted imports in {file_path}")
28
+ return True
29
+ else:
30
+ kernel.io.error(f"isort failed to format imports in {file_path}")
31
+ kernel.io.log_indent_up()
32
+
33
+ if process.stderr:
34
+ kernel.io.error(f"Error: {process.stderr}", symbol=False)
35
+ if process.stdout:
36
+ kernel.io.error(f"Output: {process.stdout}", symbol=False)
37
+
38
+ # Add detailed error properties
39
+ kernel.io.properties({"returncode": process.returncode, "command": cmd})
40
+
41
+ kernel.io.log_indent_down()
42
+ return False
@@ -0,0 +1,75 @@
1
+ from typing import Optional
2
+
3
+ from wexample_wex_core.common.kernel import Kernel
4
+ from wexample_wex_core.decorator.command import command
5
+ from wexample_wex_core.decorator.middleware import middleware
6
+ from wexample_wex_core.decorator.option import option
7
+
8
+
9
+ @option(
10
+ name="tool",
11
+ type=str,
12
+ required=False,
13
+ description="Specific tool to run (black, isort). If not specified, all tools will be run.",
14
+ )
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
+ )
22
+ @middleware(name="each_python_file", should_exist=True, expand_glob=True, recursive=True)
23
+ @command()
24
+ def python__code__format(
25
+ kernel: "Kernel",
26
+ file: str,
27
+ tool: Optional[str] = None,
28
+ stop_on_failure: bool = True,
29
+ ) -> bool:
30
+ """Format a Python file using various code formatting tools."""
31
+ from wexample_wex_addon_dev_python.commands.code.format.black import (
32
+ _code_format_black,
33
+ )
34
+ from wexample_wex_addon_dev_python.commands.code.format.isort import (
35
+ _code_format_isort,
36
+ )
37
+
38
+ # Map tool names to their format functions
39
+ tool_map = {
40
+ "black": _code_format_black,
41
+ "isort": _code_format_isort,
42
+ }
43
+
44
+ # Determine which tools to run
45
+ if tool and tool.lower() in tool_map:
46
+ # Run only the specified tool
47
+ format_functions = [tool_map[tool.lower()]]
48
+ else:
49
+ # Run all tools if no specific tool is specified or if the specified tool is invalid
50
+ if tool and tool.lower() not in tool_map:
51
+ kernel.io.warning(f"Unknown tool '{tool}', running all available tools")
52
+
53
+ # Run isort first, then black (recommended order)
54
+ format_functions = [
55
+ _code_format_isort,
56
+ _code_format_black,
57
+ ]
58
+
59
+ # Track overall success
60
+ all_formats_passed = True
61
+
62
+ # Run each format function
63
+ for format_function in format_functions:
64
+ kernel.io.title(format_function.__name__)
65
+ format_result = format_function(kernel, file)
66
+
67
+ # Update overall success status
68
+ all_formats_passed = all_formats_passed and format_result
69
+
70
+ # Stop if a format fails and stop_on_failure is True
71
+ if not format_result and stop_on_failure:
72
+ kernel.io.warning("One formatting failed")
73
+ return False
74
+
75
+ return all_formats_passed
@@ -0,0 +1,74 @@
1
+ import os.path
2
+ from typing import Set, TYPE_CHECKING
3
+
4
+ from wexample_wex_core.middleware.each_file_middleware import EachFileMiddleware
5
+
6
+ if TYPE_CHECKING:
7
+ from wexample_wex_core.common.command_request import CommandRequest
8
+
9
+
10
+ class EachPythonFileMiddleware(EachFileMiddleware):
11
+ """
12
+ Middleware for processing Python files only.
13
+ - Filters files by .py extension by default
14
+ - Ignores special directories like __pycache__ during recursion
15
+ """
16
+ # Default extension to filter
17
+ python_extension_only: bool = True
18
+
19
+ # Default list of directories to ignore during recursion
20
+ ignored_directories: Set[str] = {
21
+ "__pycache__",
22
+ ".git",
23
+ ".idea",
24
+ ".vscode",
25
+ "venv",
26
+ "env",
27
+ "node_modules",
28
+ ".pytest_cache",
29
+ ".mypy_cache",
30
+ ".ruff_cache",
31
+ }
32
+
33
+ def __init__(self, **kwargs):
34
+ # Allow overriding the default settings
35
+ if "python_extension_only" in kwargs:
36
+ self.python_extension_only = kwargs.pop("python_extension_only")
37
+
38
+ if "ignored_directories" in kwargs:
39
+ self.ignored_directories = set(kwargs.pop("ignored_directories"))
40
+
41
+ super().__init__(**kwargs)
42
+
43
+ def _should_process_item(self, request: "CommandRequest", item_path: str) -> bool:
44
+ """
45
+ Only process Python files based on extension.
46
+
47
+ Args:
48
+ item_path: Path to the item to check
49
+
50
+ Returns:
51
+ True if the item should be processed, False otherwise
52
+ """
53
+ # First check if it's a file (parent class behavior)
54
+ if not os.path.isfile(item_path):
55
+ return False
56
+
57
+ # If python_extension_only is enabled, check file extension
58
+ if self.python_extension_only:
59
+ return item_path.endswith(".py")
60
+
61
+ # Otherwise, accept all files
62
+ return True
63
+
64
+ def _should_explore_directory(self, request: "CommandRequest", directory_name: str) -> bool:
65
+ """
66
+ Skip directories that are in the ignored_directories list.
67
+
68
+ Args:
69
+ directory_name: Name of the directory to check
70
+
71
+ Returns:
72
+ False if the directory is in the ignored list, True otherwise
73
+ """
74
+ return directory_name not in self.ignored_directories
@@ -0,0 +1,13 @@
1
+ from typing import List, Type
2
+
3
+ from wexample_wex_core.common.abstract_addon_manager import AbstractAddonManager
4
+ from wexample_wex_core.middleware.abstract_middleware import AbstractMiddleware
5
+
6
+
7
+ class PythonAddonManager(AbstractAddonManager):
8
+ def get_middlewares_classes(self) -> List[Type["AbstractMiddleware"]]:
9
+ from wexample_wex_addon_dev_python.middleware.each_python_file_middleware import EachPythonFileMiddleware
10
+
11
+ return [
12
+ EachPythonFileMiddleware,
13
+ ]
@@ -0,0 +1,14 @@
1
+ Metadata-Version: 2.4
2
+ Name: wexample-wex-addon-dev-python
3
+ Version: 0.0.33
4
+ Summary: Python dev addon for wex
5
+ Author-email: weeger <contact@wexample.com>
6
+ License: MIT
7
+ Project-URL: homepage, https://github.com/wexample/python-wex-dev-python
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.6
12
+ Description-Content-Type: text/markdown
13
+
14
+ # Wex Addon Dev Python
@@ -0,0 +1,19 @@
1
+ README.md
2
+ pyproject.toml
3
+ wexample_wex_addon_dev_python/__init__.py
4
+ wexample_wex_addon_dev_python/python_addon_manager.py
5
+ wexample_wex_addon_dev_python.egg-info/PKG-INFO
6
+ wexample_wex_addon_dev_python.egg-info/SOURCES.txt
7
+ wexample_wex_addon_dev_python.egg-info/dependency_links.txt
8
+ wexample_wex_addon_dev_python.egg-info/top_level.txt
9
+ wexample_wex_addon_dev_python/commands/code/check.py
10
+ wexample_wex_addon_dev_python/commands/code/format.py
11
+ wexample_wex_addon_dev_python/commands/code/check/__init__.py
12
+ wexample_wex_addon_dev_python/commands/code/check/mypy.py
13
+ wexample_wex_addon_dev_python/commands/code/check/pylint.py
14
+ wexample_wex_addon_dev_python/commands/code/check/pyright.py
15
+ wexample_wex_addon_dev_python/commands/code/format/__init__.py
16
+ wexample_wex_addon_dev_python/commands/code/format/black.py
17
+ wexample_wex_addon_dev_python/commands/code/format/isort.py
18
+ wexample_wex_addon_dev_python/middleware/__init__.py
19
+ wexample_wex_addon_dev_python/middleware/each_python_file_middleware.py