Skip to content

Commit

Permalink
Add mypy to the pre-commit hooks (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtomlinson authored Jun 28, 2024
1 parent a87c593 commit 851c4d5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@ repos:
- --use-current-year
- --no-extra-eol
- --detect-license-in-X-top-lines=5
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.10.1'
hooks:
- id: mypy
exclude: "examples"
additional_dependencies: [types-pyyaml>=6.0]
20 changes: 10 additions & 10 deletions kr8s/_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
if TYPE_CHECKING:
from kr8s._objects import APIObject

STDIN_CHANNEL = 0
STDOUT_CHANNEL = 1
STDERR_CHANNEL = 2
ERROR_CHANNEL = 3
RESIZE_CHANNEL = 4
CLOSE_CHANNEL = 255
EXEC_PROTOCOL = "v4.channel.k8s.io"
STDIN_CHANNEL: int = 0
STDOUT_CHANNEL: int = 1
STDERR_CHANNEL: int = 2
ERROR_CHANNEL: int = 3
RESIZE_CHANNEL: int = 4
CLOSE_CHANNEL: int = 255
EXEC_PROTOCOL: str = "v4.channel.k8s.io"


class Exec:
Expand Down Expand Up @@ -73,10 +73,10 @@ async def run(
f"{ws.protocol}, only with v5.channel.k8s.io"
)
if isinstance(self._stdin, str):
await ws.send_bytes(STDIN_CHANNEL.to_bytes() + self._stdin.encode())
await ws.send_bytes(STDIN_CHANNEL.to_bytes() + self._stdin.encode()) # type: ignore
else:
await ws.send_bytes(STDIN_CHANNEL.to_bytes() + self._stdin.read())
await ws.send_bytes(CLOSE_CHANNEL.to_bytes() + STDIN_CHANNEL.to_bytes())
await ws.send_bytes(STDIN_CHANNEL.to_bytes() + self._stdin.read()) # type: ignore
await ws.send_bytes(CLOSE_CHANNEL.to_bytes() + STDIN_CHANNEL.to_bytes()) # type: ignore
while True:
message = await ws.receive_bytes()
channel, message = int(message[0]), message[1:]
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,6 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

# Assume Python 3.10.
target-version = "py310"

[tool.mypy]
exclude = ["examples"]

0 comments on commit 851c4d5

Please sign in to comment.