Skip to content

Commit 8d05de8

Browse files
authored
PYSCAN-18: Setup type checker (#3)
1 parent ab91f49 commit 8d05de8

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,22 @@ Run `python3 -m twine upload --repository testpypi dist/*`
3737
`--repository testpypi` can be removed to push to the prod PyPI instance.
3838
Also `dist/*` can be a bit more precise to upload a specific version of the binaries
3939

40-
## Before push
40+
# Tooling
41+
## Formatting
4142

42-
Please check if all files have a license header.
43+
Run `hatch run tool:format` to run the formatter on all files.
44+
45+
## Type checking
46+
47+
Run `hatch run tool:type_check` to execute the type checking on all files.
48+
49+
## License header
50+
51+
Before pushing, please check if all files have a license header.
4352
If not all files have a license header please execute: `hatch run tool:license`.
4453

45-
## License
54+
55+
# License
4656

4757
Copyright 2011-2023 SonarSource.
4858

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@ python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
5858
[tool.hatch.envs.tool]
5959
dependencies = [
6060
"licenseheaders",
61-
"black"
61+
"black",
62+
"mypy"
6263
]
6364

6465
[tool.hatch.envs.tool.scripts]
6566
license = 'python -m licenseheaders -t license_header.tmpl -o "SonarSource SA" -y 2011-2023 -n "Sonar Scanner Python" -E .py'
6667
format = 'python -m black src/ tests/ --check'
68+
type_check = "python -m mypy src/ tests/ --ignore-missing-imports"
6769

6870
[tool.pytest.ini_options]
6971
pythonpath = [

src/py_sonar_scanner/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def _read_jvm_args(self) -> list[str]:
8080
return scan_arguments
8181

8282
def _read_toml_args(self) -> list[str]:
83-
scan_arguments = []
83+
scan_arguments: list[str] = []
8484
try:
8585
if os.path.isfile('pyproject.toml'):
8686
with open('pyproject.toml', 'r') as file:

src/py_sonar_scanner/scanner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def execute_command(self) -> Popen:
5454
cmd = self.compute_command()
5555
return Popen(cmd, stdout=PIPE, stderr=PIPE)
5656

57-
def _print_output(self, stream: list[str]):
57+
def _print_output(self, stream: list[bytes]):
5858
for line in stream:
5959
decoded_line = line.decode('utf-8')
6060
print(decoded_line, end='', flush=True)

0 commit comments

Comments
 (0)