ruff-odoo 0.16.2.1__py3-none-linux_armv6l.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.
ruff/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ from __future__ import annotations
2
+
3
+ from ._find_ruff import find_ruff_bin
4
+
5
+ __all__ = ["find_ruff_bin"]
ruff/__main__.py ADDED
@@ -0,0 +1,27 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ import sys
5
+
6
+ from ruff import find_ruff_bin
7
+
8
+
9
+ def _run() -> None:
10
+ ruff = find_ruff_bin()
11
+
12
+ if sys.platform == "win32":
13
+ import subprocess
14
+
15
+ # Avoid emitting a traceback on interrupt
16
+ try:
17
+ completed_process = subprocess.run([ruff, *sys.argv[1:]])
18
+ except KeyboardInterrupt:
19
+ sys.exit(2)
20
+
21
+ sys.exit(completed_process.returncode)
22
+ else:
23
+ os.execvp(ruff, [ruff, *sys.argv[1:]])
24
+
25
+
26
+ if __name__ == "__main__":
27
+ _run()
ruff/_find_ruff.py ADDED
@@ -0,0 +1,104 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ import sys
5
+ import sysconfig
6
+
7
+
8
+ class RuffNotFound(FileNotFoundError): ...
9
+
10
+
11
+ def find_ruff_bin() -> str:
12
+ """Return the ruff binary path."""
13
+
14
+ ruff_exe = "ruff" + sysconfig.get_config_var("EXE")
15
+
16
+ targets = [
17
+ # The scripts directory for the current Python
18
+ sysconfig.get_path("scripts"),
19
+ # The scripts directory for the base prefix
20
+ sysconfig.get_path("scripts", vars={"base": sys.base_prefix}),
21
+ # Above the package root, e.g., from `pip install --prefix` or `uv run --with`
22
+ (
23
+ # On Windows, with module path `<prefix>/Lib/site-packages/ruff`
24
+ _join(
25
+ _matching_parents(_module_path(), "Lib/site-packages/ruff"), "Scripts"
26
+ )
27
+ if sys.platform == "win32"
28
+ # On Unix, with module path `<prefix>/lib/python3.13/site-packages/ruff`
29
+ else _join(
30
+ _matching_parents(_module_path(), "lib/python*/site-packages/ruff"),
31
+ "bin",
32
+ )
33
+ ),
34
+ # Adjacent to the package root, e.g., from `pip install --target`
35
+ # with module path `<target>/ruff`
36
+ _join(_matching_parents(_module_path(), "ruff"), "bin"),
37
+ # The user scheme scripts directory, e.g., `~/.local/bin`
38
+ sysconfig.get_path("scripts", scheme=_user_scheme()),
39
+ ]
40
+
41
+ seen = []
42
+ for target in targets:
43
+ if not target:
44
+ continue
45
+ if target in seen:
46
+ continue
47
+ seen.append(target)
48
+ path = os.path.join(target, ruff_exe)
49
+ if os.path.isfile(path):
50
+ return path
51
+
52
+ locations = "\n".join(f" - {target}" for target in seen)
53
+ raise RuffNotFound(
54
+ f"Could not find the ruff binary in any of the following locations:\n{locations}\n"
55
+ )
56
+
57
+
58
+ def _module_path() -> str | None:
59
+ path = os.path.dirname(__file__)
60
+ return path
61
+
62
+
63
+ def _matching_parents(path: str | None, match: str) -> str | None:
64
+ """
65
+ Return the parent directory of `path` after trimming a `match` from the end.
66
+ The match is expected to contain `/` as a path separator, while the `path`
67
+ is expected to use the platform's path separator (e.g., `os.sep`). The path
68
+ components are compared case-insensitively and a `*` wildcard can be used
69
+ in the `match`.
70
+ """
71
+ from fnmatch import fnmatch
72
+
73
+ if not path:
74
+ return None
75
+ parts = path.split(os.sep)
76
+ match_parts = match.split("/")
77
+ if len(parts) < len(match_parts):
78
+ return None
79
+
80
+ if not all(
81
+ fnmatch(part, match_part)
82
+ for part, match_part in zip(reversed(parts), reversed(match_parts))
83
+ ):
84
+ return None
85
+
86
+ return os.sep.join(parts[: -len(match_parts)])
87
+
88
+
89
+ def _join(path: str | None, *parts: str) -> str | None:
90
+ if not path:
91
+ return None
92
+ return os.path.join(path, *parts)
93
+
94
+
95
+ def _user_scheme() -> str:
96
+ if sys.version_info >= (3, 10):
97
+ user_scheme = sysconfig.get_preferred_scheme("user")
98
+ elif os.name == "nt":
99
+ user_scheme = "nt_user"
100
+ elif sys.platform == "darwin" and sys._framework: # ty: ignore[unresolved-attribute]
101
+ user_scheme = "osx_framework_user"
102
+ else:
103
+ user_scheme = "posix_user"
104
+ return user_scheme
Binary file