Skip to content

Commit cf17a58

Browse files
authored
Switch to Pyright, format with Ruff (#97)
* Fix `get_artifact_architecture()` * Fix `get_artifact_os()` * Specify type: ignore warning * Upgrade harborapi * Upgrade pydantic * Fix `list_artifacts` * Remove mypy dev dependency * Exclude package init from ruff * Add kwargs types for console functions * Refactor `artifact vulnerability summary` Improve type checking, declare sorting functions outside command * Upadte pre-commit hooks * Replace mypy with pyright * Enable strict mode, ignore scripts * Perform all linting and formatting with ruff * Remove mypy configuration * Fix all pylance strict mode errors * Fix `replace_none()` when None is passed in * Fix number prompt default value
1 parent c8a3572 commit cf17a58

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+545
-851
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.4.0
5+
rev: v4.6.0
66
hooks:
77
- id: trailing-whitespace
88
- id: end-of-file-fixer
@@ -14,26 +14,15 @@ repos:
1414
# hooks:
1515
# - id: pyupgrade
1616
# args: [--py38-plus]
17-
- repo: https://github.com/asottile/reorder_python_imports
18-
rev: v3.10.0
19-
hooks:
20-
- id: reorder-python-imports
21-
args: [--py38-plus, --add-import, "from __future__ import annotations"]
2217
- repo: https://github.com/charliermarsh/ruff-pre-commit
23-
rev: "v0.2.0"
18+
rev: "v0.4.10"
2419
hooks:
2520
# Run the linter.
2621
- id: ruff
2722
args: [--fix]
2823
# Run the formatter.
2924
- id: ruff-format
30-
- repo: https://github.com/pre-commit/mirrors-mypy
31-
rev: "v1.5.1"
25+
- repo: https://github.com/RobertCraigie/pyright-python
26+
rev: v1.1.368
3227
hooks:
33-
- id: mypy
34-
additional_dependencies: [types-all, rich]
35-
language: python
36-
types: [python]
37-
files: '.*\.py[i]?'
38-
exclude: ^tests/
39-
args: [--config-file, pyproject.toml, --ignore-missing-imports]
28+
- id: pyright

docs/scripts/gen_cli_data.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
The commands are run in a limited environment (no color, limited width) to
55
make the output more readable in the documentation.
66
"""
7+
78
from __future__ import annotations
89

910
import os

docs/scripts/gen_cli_options.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from typing import NamedTuple
66

77
import yaml # type: ignore
8-
98
from harbor_cli.deprecation import Deprecated
109
from harbor_cli.main import app
1110
from harbor_cli.utils.commands import get_app_callback_options

docs/scripts/gen_command_list.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@
77
from typing import List
88

99
import yaml # type: ignore
10-
1110
from harbor_cli.main import app
1211
from harbor_cli.utils.commands import get_app_commands
1312

14-
1513
sys.path.append(Path(__file__).parent.as_posix())
1614
from common import DATA_DIR # noqa
1715

docs/scripts/gen_command_pages.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Generate the code reference pages and navigation."""
2+
23
from __future__ import annotations
34

45
import sys
@@ -8,11 +9,10 @@
89

910
import jinja2
1011
import yaml # type: ignore
11-
from sanitize_filename import sanitize
12-
1312
from harbor_cli.main import app
1413
from harbor_cli.models import CommandSummary
1514
from harbor_cli.utils.commands import get_app_commands
15+
from sanitize_filename import sanitize
1616

1717
sys.path.append(Path(__file__).parent.as_posix())
1818
sys.path.append(Path(__file__).parent.parent.parent.as_posix())

docs/scripts/gen_formats.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from pathlib import Path
55

66
import yaml # type: ignore
7-
87
from harbor_cli.format import OutputFormat
98

109
sys.path.append(Path(__file__).parent.as_posix())

harbor_cli/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# SPDX-License-Identifier: MIT
44
from __future__ import annotations
55

6-
from . import logs # noreorder # configure logger first as side-effect
6+
from . import logs # type: ignore # noreorder # configure logger first as side-effect
77
from . import *

harbor_cli/__main__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22

33
from .main import main
44

5-
65
if __name__ == "__main__":
76
main()

harbor_cli/commands/api/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""""""
2+
23
from __future__ import annotations
34

45
import typer

0 commit comments

Comments
 (0)