Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Support of Python 3.15.
- Print only short error message in case of failure.
- Update --help message for CLI.
- Internal: Use poethepoet as taskrunner.
- Internal: Update GitHub workflow actions to use latest versions.

## [1.3.1] - 2026-04-09
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ $ pyright . --outputjson | pyright-to-gitlab --prefix my-app > code-quality.jso
## Testing
To run the tests, execute
```shell
$ uv run pytest tests/
$ uv run poe check
```
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ pypi = "https://pypi.org/project/pyright-to-gitlab"
[project.scripts]
pyright-to-gitlab = 'pyright_to_gitlab:cli'

[tool.poe.tasks]
typing = "pyright src/ tests/"
pytest = "pytest tests"
lint = [{cmd="ruff format src/ tests/"}, {cmd="ruff check --fix src/ tests/"}]
check = ["lint", "typing", "pytest"]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
Expand All @@ -44,6 +50,7 @@ artifacts = ["src/py.typed"]

[dependency-groups]
dev = [
"poethepoet>=0.30.0",
"pyright>=0.0.13.post0",
"pytest>=7.0.1",
"pytest-cov>=4.0.0",
Expand Down
30 changes: 18 additions & 12 deletions src/pyright_to_gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,38 +172,44 @@ def cli() -> None:
"""Parse arguments and call the conversion function."""
parser = argparse.ArgumentParser(
description=textwrap.dedent("""
Convert pyright.json to GitLab Code Quality report.
By default, reads from stdin and writes to stdout."""),
Convert Pyright JSON output to a GitLab Code Quality report.

Input defaults to stdin and output defaults to stdout.
Use '-' explicitly for stdin/stdout when mixing with file paths."""),
epilog=textwrap.dedent(
"""

Example usage:
> python pyright . --outputjson | pyright-to-gitlab > gitlab_code_quality.json
> pyright-to-gitlab -i pyright.json -o gitlab_code_quality.json
"""
Examples:
pyright . --outputjson | pyright-to-gitlab > gl-code-quality.json
pyright-to-gitlab -i pyright.json -o gl-code-quality.json
pyright-to-gitlab --prefix backend/ -i pyright.json -o -
pyright-to-gitlab -i pyright.json --indent 0
"""
),
formatter_class=argparse.RawDescriptionHelpFormatter,
formatter_class=argparse.RawTextHelpFormatter,
)
parser.add_argument(
"-i",
"--input",
type=str,
metavar="INPUT",
default="-",
help="Input file (default: stdin)",
help="Path to Pyright JSON input (default: -). Use - to read from stdin.",
)
parser.add_argument(
"-o",
"--output",
type=str,
default="-",
help="Output file (default: stdout)",
metavar="OUTPUT",
help="Path for GitLab Code Quality JSON (default: -)."
" Use - to write to stdout.",
)
parser.add_argument(
"--prefix",
type=str,
metavar="PATH_PREFIX",
default="",
help="Prefix path to add to each file entry. This can be used if pyright is run"
" from a subdirectory of the repository. (default: empty string)",
help="Prefix added to each reported file path, e.g. 'backend/' for monorepos.",
)
parser.add_argument("--version", action="version", version=f"%(prog)s {VERSION}")
args = parser.parse_args()
Expand Down
Loading
Loading