Skip to content

Commit

Permalink
Fix issues passing mypy --strict (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
twizmwazin authored Oct 10, 2023
1 parent 36126a9 commit 06c5548
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 22 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,5 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install binharness
run: pip install -e .[dev]
- name: Run ruff
run: ruff .
- name: Run black
run: black --check .
- name: Run mypy
run: mypy binharness
- name: Run pytest
run: pytest
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ repos:
- id: rst-directive-colons
- id: rst-inline-touching-normal

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
hooks:
- id: mypy
args: [--strict]

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.14
hooks:
Expand Down
3 changes: 2 additions & 1 deletion binharness/localenvironment.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def get_tempdir(self: LocalEnvironment) -> Path:
class LocalProcess(Process):
"""A process running in a local environment."""

popen: subprocess.Popen
popen: subprocess.Popen[bytes]

def __init__(
self: LocalProcess,
Expand All @@ -88,6 +88,7 @@ def __init__(
stderr=subprocess.PIPE,
env=env,
cwd=cwd,
universal_newlines=False,
)

@property
Expand Down
26 changes: 13 additions & 13 deletions binharness/types/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,42 @@
class IO(Protocol[AnyStr]):
"""A file-like object."""

def close(self: IO) -> None:
def close(self: IO[AnyStr]) -> None:
"""Close the file."""

@property
def closed(self: IO) -> bool:
def closed(self: IO[AnyStr]) -> bool:
"""Whether the file is closed."""

def flush(self: IO) -> None:
def flush(self: IO[AnyStr]) -> None:
"""Flush the file."""

def read(self: IO, n: int = -1) -> AnyStr:
def read(self: IO[AnyStr], n: int = -1) -> AnyStr:
"""Read n bytes from the file."""

def readable(self: IO) -> bool:
def readable(self: IO[AnyStr]) -> bool:
"""Whether the file is readable."""

def readline(self: IO, limit: int = -1) -> AnyStr:
def readline(self: IO[AnyStr], limit: int = -1) -> AnyStr:
"""Read a line from the file."""

def readlines(self: IO, hint: int = -1) -> list[AnyStr]:
def readlines(self: IO[AnyStr], hint: int = -1) -> list[AnyStr]:
"""Read lines from the file."""

def seek(self: IO, offset: int, whence: int = 0) -> int | None:
def seek(self: IO[AnyStr], offset: int, whence: int = 0) -> int | None:
"""Seek to a position in the file."""

def seekable(self: IO) -> bool:
def seekable(self: IO[AnyStr]) -> bool:
"""Whether the file is seekable."""

def tell(self: IO) -> int:
def tell(self: IO[AnyStr]) -> int:
"""Get the current position in the file."""

def writable(self: IO) -> bool:
def writable(self: IO[AnyStr]) -> bool:
"""Whether the file is writable."""

def write(self: IO, s: AnyStr) -> int | None:
def write(self: IO[AnyStr], s: AnyStr) -> int | None:
"""Write to the file."""

def writelines(self: IO, lines: list[AnyStr]) -> None:
def writelines(self: IO[AnyStr], lines: list[AnyStr]) -> None:
"""Write lines to the file."""
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ dynamic = ["version"]
dev = [
"black>=23.3.0",
"coverage[toml]>=7.2.3",
"mock-ssh-server>=0.9.1",
"mypy>=1.2.0",
"pre-commit>=3.2.2",
"pytest>=7.3.1",
"pytest-cov>=4.0.0",
"ruff>=0.0.262",
"types-paramiko>=3.0.0.7",
]

[project.urls]
Expand Down

0 comments on commit 06c5548

Please sign in to comment.