pyright-to-gitlab 1.0.2__tar.gz → 1.1.0__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.
- {pyright_to_gitlab-1.0.2 → pyright_to_gitlab-1.1.0}/CHANGELOG.md +5 -0
- {pyright_to_gitlab-1.0.2 → pyright_to_gitlab-1.1.0}/PKG-INFO +1 -1
- {pyright_to_gitlab-1.0.2 → pyright_to_gitlab-1.1.0}/pyproject.toml +1 -1
- {pyright_to_gitlab-1.0.2 → pyright_to_gitlab-1.1.0}/src/pyright_to_gitlab.py +33 -7
- {pyright_to_gitlab-1.0.2 → pyright_to_gitlab-1.1.0}/tests/test_main.py +35 -0
- {pyright_to_gitlab-1.0.2 → pyright_to_gitlab-1.1.0}/uv.lock +1 -1
- {pyright_to_gitlab-1.0.2 → pyright_to_gitlab-1.1.0}/.github/workflows/python.yml +0 -0
- {pyright_to_gitlab-1.0.2 → pyright_to_gitlab-1.1.0}/.github/workflows/testing.yml +0 -0
- {pyright_to_gitlab-1.0.2 → pyright_to_gitlab-1.1.0}/.gitignore +0 -0
- {pyright_to_gitlab-1.0.2 → pyright_to_gitlab-1.1.0}/LICENSE +0 -0
- {pyright_to_gitlab-1.0.2 → pyright_to_gitlab-1.1.0}/README.md +0 -0
- {pyright_to_gitlab-1.0.2 → pyright_to_gitlab-1.1.0}/tests/__init__.py +0 -0
|
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
## [Upcoming]
|
|
9
|
+
## [1.1.0] - 2025-06-03
|
|
10
|
+
### Added
|
|
11
|
+
- Support for -i/--input and -o/--output options to specify input and output files.
|
|
9
12
|
|
|
10
13
|
## [1.0.2] - 2025-06-02
|
|
11
14
|
### Added
|
|
@@ -13,5 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
13
16
|
- Advertise the no-dependency in the README.md.
|
|
14
17
|
|
|
15
18
|
## [1.0.1] - 2025-06-02
|
|
19
|
+
- Support for custom path prefix with the `--prefix` option.
|
|
20
|
+
## [1.0.0] - 2025-06-02
|
|
16
21
|
Initial release.
|
|
17
22
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyright-to-gitlab
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: Convert Pyright JSON output to GitLab CI/CD format
|
|
5
5
|
Project-URL: homepage, https://github.com/schollm/pyright-to-gitlab/
|
|
6
6
|
Project-URL: repository, https://github.com/schollm/pyright-to-gitlab/
|
|
@@ -4,10 +4,11 @@ import argparse
|
|
|
4
4
|
import hashlib
|
|
5
5
|
import json
|
|
6
6
|
import sys
|
|
7
|
-
|
|
7
|
+
import textwrap
|
|
8
|
+
from typing import TextIO, cast
|
|
8
9
|
|
|
9
10
|
|
|
10
|
-
def _pyright_to_gitlab(prefix: str = "") -> str:
|
|
11
|
+
def _pyright_to_gitlab(input_: TextIO, prefix: str = "") -> str:
|
|
11
12
|
"""Convert pyright.json output to GitLab Code Quality report format.
|
|
12
13
|
|
|
13
14
|
:arg prefix: A string to prepend to each file path in the output.
|
|
@@ -17,7 +18,7 @@ def _pyright_to_gitlab(prefix: str = "") -> str:
|
|
|
17
18
|
Pyright format at https://github.com/microsoft/pyright/blob/main/docs/command-line.md
|
|
18
19
|
Gitlab format at https://docs.gitlab.com/ci/testing/code_quality/#code-quality-report-format
|
|
19
20
|
"""
|
|
20
|
-
data = cast("dict", json.load(
|
|
21
|
+
data = cast("dict", json.load(input_))
|
|
21
22
|
|
|
22
23
|
issues = []
|
|
23
24
|
for issue in data.get("generalDiagnostics", []):
|
|
@@ -49,17 +50,42 @@ def _pyright_to_gitlab(prefix: str = "") -> str:
|
|
|
49
50
|
def main() -> None:
|
|
50
51
|
"""Parse arguments and call the conversion function."""
|
|
51
52
|
parser = argparse.ArgumentParser(
|
|
52
|
-
description=
|
|
53
|
+
description=textwrap.dedent("""
|
|
54
|
+
Convert pyright.json to GitLab Code Quality report.
|
|
55
|
+
By default, reads from stdin and writes to stdout."""),
|
|
56
|
+
epilog=textwrap.dedent(
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
Example usage:
|
|
60
|
+
> python pyright . --outputjson | pyright-to-gitlab > gitlab_code_quality.json
|
|
61
|
+
> pyright-to-gitlab -i pyright.json -o gitlab_code_quality.json
|
|
62
|
+
"""
|
|
63
|
+
),
|
|
64
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
65
|
+
)
|
|
66
|
+
parser.add_argument(
|
|
67
|
+
"-i",
|
|
68
|
+
"--input",
|
|
69
|
+
type=argparse.FileType("r"),
|
|
70
|
+
default=sys.stdin,
|
|
71
|
+
help="Input file (default: stdin)",
|
|
72
|
+
)
|
|
73
|
+
parser.add_argument(
|
|
74
|
+
"-o",
|
|
75
|
+
"--output",
|
|
76
|
+
type=argparse.FileType("w"),
|
|
77
|
+
default=sys.stdout,
|
|
78
|
+
help="Output file (default: stdout)",
|
|
53
79
|
)
|
|
54
80
|
parser.add_argument(
|
|
55
81
|
"--prefix",
|
|
56
82
|
type=str,
|
|
57
83
|
default="",
|
|
58
|
-
help="Prefix to add to each file
|
|
84
|
+
help="Prefix to add to each file entry. This can be used if pyright is run"
|
|
85
|
+
" from a subdirectory of the repository. (default: empty string)",
|
|
59
86
|
)
|
|
60
87
|
args = parser.parse_args()
|
|
61
|
-
|
|
62
|
-
print(_pyright_to_gitlab(prefix=args.prefix)) # noqa: T201
|
|
88
|
+
args.output.write(_pyright_to_gitlab(input_=args.input, prefix=args.prefix))
|
|
63
89
|
|
|
64
90
|
|
|
65
91
|
if __name__ == "__main__": # pragma: no cover
|
|
@@ -4,6 +4,10 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import io
|
|
6
6
|
import json
|
|
7
|
+
from typing import TYPE_CHECKING
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from pathlib import Path
|
|
7
11
|
|
|
8
12
|
import pytest
|
|
9
13
|
|
|
@@ -93,6 +97,37 @@ def test(
|
|
|
93
97
|
assert json.loads(captured.out) == gitlab
|
|
94
98
|
|
|
95
99
|
|
|
100
|
+
@pytest.mark.parametrize(
|
|
101
|
+
("pyright", "gitlab"),
|
|
102
|
+
[
|
|
103
|
+
({}, []), # Empty input should yield empty output
|
|
104
|
+
(PYRIGHT, GITLAB),
|
|
105
|
+
],
|
|
106
|
+
)
|
|
107
|
+
def test_input_output_file(
|
|
108
|
+
monkeypatch: pytest.MonkeyPatch,
|
|
109
|
+
tmp_path: Path,
|
|
110
|
+
pyright: dict,
|
|
111
|
+
gitlab: list[dict],
|
|
112
|
+
) -> None:
|
|
113
|
+
"""Test that the pyright.json is converted to GitLab Code Quality report format."""
|
|
114
|
+
input_file = tmp_path / "pyright.json"
|
|
115
|
+
input_file.write_text(json.dumps(pyright))
|
|
116
|
+
output_file = tmp_path / "gitlab.json"
|
|
117
|
+
monkeypatch.setattr(
|
|
118
|
+
"sys.argv",
|
|
119
|
+
[
|
|
120
|
+
"pyright_to_gitlab.py",
|
|
121
|
+
"-i",
|
|
122
|
+
input_file.as_posix(),
|
|
123
|
+
"-o",
|
|
124
|
+
output_file.as_posix(),
|
|
125
|
+
],
|
|
126
|
+
)
|
|
127
|
+
main()
|
|
128
|
+
assert json.loads(output_file.read_text("utf-8")) == gitlab
|
|
129
|
+
|
|
130
|
+
|
|
96
131
|
@pytest.mark.parametrize(
|
|
97
132
|
("pyright", "gitlab"),
|
|
98
133
|
[
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|