meson-python-sources-fixer 1.0__tar.gz → 1.1__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.
- {meson_python_sources_fixer-1.0 → meson_python_sources_fixer-1.1}/PKG-INFO +2 -2
- {meson_python_sources_fixer-1.0 → meson_python_sources_fixer-1.1}/README.md +1 -1
- {meson_python_sources_fixer-1.0 → meson_python_sources_fixer-1.1}/meson_python_sources_fixer.egg-info/PKG-INFO +2 -2
- {meson_python_sources_fixer-1.0 → meson_python_sources_fixer-1.1}/meson_python_sources_fixer.py +9 -10
- {meson_python_sources_fixer-1.0 → meson_python_sources_fixer-1.1}/pyproject.toml +1 -1
- {meson_python_sources_fixer-1.0 → meson_python_sources_fixer-1.1}/LICENSE +0 -0
- {meson_python_sources_fixer-1.0 → meson_python_sources_fixer-1.1}/meson_python_sources_fixer.egg-info/SOURCES.txt +0 -0
- {meson_python_sources_fixer-1.0 → meson_python_sources_fixer-1.1}/meson_python_sources_fixer.egg-info/dependency_links.txt +0 -0
- {meson_python_sources_fixer-1.0 → meson_python_sources_fixer-1.1}/meson_python_sources_fixer.egg-info/entry_points.txt +0 -0
- {meson_python_sources_fixer-1.0 → meson_python_sources_fixer-1.1}/meson_python_sources_fixer.egg-info/requires.txt +0 -0
- {meson_python_sources_fixer-1.0 → meson_python_sources_fixer-1.1}/meson_python_sources_fixer.egg-info/top_level.txt +0 -0
- {meson_python_sources_fixer-1.0 → meson_python_sources_fixer-1.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: meson-python-sources-fixer
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1
|
|
4
4
|
Summary: Linter to list all Python sources in meson.build
|
|
5
5
|
Author-email: Omar Sandoval <osandov@osandov.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -27,7 +27,7 @@ To use it via [pre-commit](https://pre-commit.com/), add the following to your
|
|
|
27
27
|
```yaml
|
|
28
28
|
repos:
|
|
29
29
|
- repo: https://github.com/osandov/meson-python-sources-fixer
|
|
30
|
-
rev: v1.
|
|
30
|
+
rev: v1.1
|
|
31
31
|
hooks:
|
|
32
32
|
- id: meson-python-sources-fixer
|
|
33
33
|
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: meson-python-sources-fixer
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1
|
|
4
4
|
Summary: Linter to list all Python sources in meson.build
|
|
5
5
|
Author-email: Omar Sandoval <osandov@osandov.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -27,7 +27,7 @@ To use it via [pre-commit](https://pre-commit.com/), add the following to your
|
|
|
27
27
|
```yaml
|
|
28
28
|
repos:
|
|
29
29
|
- repo: https://github.com/osandov/meson-python-sources-fixer
|
|
30
|
-
rev: v1.
|
|
30
|
+
rev: v1.1
|
|
31
31
|
hooks:
|
|
32
32
|
- id: meson-python-sources-fixer
|
|
33
33
|
```
|
{meson_python_sources_fixer-1.0 → meson_python_sources_fixer-1.1}/meson_python_sources_fixer.py
RENAMED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import argparse
|
|
6
6
|
import ast
|
|
7
7
|
import difflib
|
|
8
|
+
import os
|
|
8
9
|
from pathlib import Path
|
|
9
10
|
import sys
|
|
10
11
|
from typing import Dict, Iterable, Literal, Mapping, Optional, Set
|
|
@@ -35,7 +36,7 @@ def print_error(s: str, *, color: bool) -> None:
|
|
|
35
36
|
if color:
|
|
36
37
|
sys.stderr.write("\033[31merror:\033[m " + s + "\n")
|
|
37
38
|
else:
|
|
38
|
-
print(s, file=sys.stderr)
|
|
39
|
+
print("error:", s, file=sys.stderr)
|
|
39
40
|
|
|
40
41
|
|
|
41
42
|
def print_diff(
|
|
@@ -79,8 +80,8 @@ def print_diff(
|
|
|
79
80
|
sys.stdout.write(line)
|
|
80
81
|
|
|
81
82
|
|
|
82
|
-
STRING_PATTERN = r"'(?:\\.|[^'])*'"
|
|
83
|
-
COMMENT_PATTERN = r"[#]
|
|
83
|
+
STRING_PATTERN = r"'(?:\\.|[^'\\])*'"
|
|
84
|
+
COMMENT_PATTERN = r"[#].*+"
|
|
84
85
|
NON_NEWLINE_WHITESPACE = r"[^\S\n]*"
|
|
85
86
|
WHITESPACE_OR_COMMENT_CAPTURE = r"(?:\s|(?&comment))*"
|
|
86
87
|
WHITESPACE_OR_COMMENT_EOL_CAPTURE = r"[^\S\n]*(?&comment)?$"
|
|
@@ -120,9 +121,6 @@ def find_py_installation(contents: str) -> Optional[str]:
|
|
|
120
121
|
PY_INSTALLATION_PATTERN, contents, flags=regex.MULTILINE | regex.VERBOSE
|
|
121
122
|
)
|
|
122
123
|
return match.group(1) if match else None
|
|
123
|
-
if not match:
|
|
124
|
-
raise LookupError("import('python').find_installation() not found")
|
|
125
|
-
return match.group(1)
|
|
126
124
|
|
|
127
125
|
|
|
128
126
|
SUBDIR_PATTERN = rf"""
|
|
@@ -149,13 +147,14 @@ def find_subdirs(contents: str) -> Iterable[str]:
|
|
|
149
147
|
|
|
150
148
|
|
|
151
149
|
def is_python_source(name: str) -> bool:
|
|
152
|
-
return name.endswith(".py"
|
|
150
|
+
return name.endswith((".py", ".pyi")) or os.path.basename(name) == "py.typed"
|
|
153
151
|
|
|
154
152
|
|
|
155
153
|
def find_package_sources(source_path: Path, install_path: Path) -> Dict[str, Set[str]]:
|
|
156
154
|
sources = {}
|
|
157
155
|
if (source_path / "__init__.py").exists():
|
|
158
|
-
for
|
|
156
|
+
for root_str, dirs, files in os.walk(source_path):
|
|
157
|
+
root = Path(root_str)
|
|
159
158
|
dirs[:] = [dir for dir in dirs if (root / dir / "__init__.py").exists()]
|
|
160
159
|
|
|
161
160
|
relative = root.relative_to(source_path)
|
|
@@ -251,7 +250,7 @@ def fix_package_meson_build(
|
|
|
251
250
|
contents,
|
|
252
251
|
flags=regex.MULTILINE | regex.VERBOSE,
|
|
253
252
|
):
|
|
254
|
-
if match.group("unrecognized"):
|
|
253
|
+
if match.group("unrecognized") is not None:
|
|
255
254
|
raise CannotFixError(
|
|
256
255
|
f"unrecognized {py_installation}.install_sources() syntax"
|
|
257
256
|
)
|
|
@@ -266,7 +265,7 @@ def fix_package_meson_build(
|
|
|
266
265
|
raise CannotFixError(
|
|
267
266
|
f"unrecognized {py_installation}.install_sources() subdir syntax"
|
|
268
267
|
)
|
|
269
|
-
subdir = ast.literal_eval(subdir_arg)
|
|
268
|
+
subdir = str(Path(ast.literal_eval(subdir_arg)))
|
|
270
269
|
|
|
271
270
|
if subdir in matches:
|
|
272
271
|
raise CannotFixError(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|