Skip to content

Commit

Permalink
Finalisation + extend tox typing to include all platforms.
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasBackx committed Dec 22, 2024
1 parent 81b48a3 commit db8be1f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/click/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from types import TracebackType
from weakref import WeakKeyDictionary

CYGWIN = sys.platform == "cygwin"
WIN = sys.platform == "win32"
CYGWIN = sys.platform.startswith("cygwin")
WIN = sys.platform.startswith("win")
auto_wrap_for_ansi: t.Callable[[t.TextIO], t.TextIO] | None = None
_ansi_re = re.compile(r"\033\[[;?0-9]*[a-zA-Z]")

Expand Down
5 changes: 2 additions & 3 deletions src/click/_termui_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,12 +711,11 @@ def getchar(echo: bool) -> str:
#
# Anyway, Click doesn't claim to do this Right(tm), and using `getwch`
# is doing the right thing in more situations than with `getch`.
func: t.Callable[[], str]

if echo:
func = msvcrt.getwche
func = t.cast(t.Callable[[], str], msvcrt.getwche)
else:
func = msvcrt.getwch
func = t.cast(t.Callable[[], str], msvcrt.getwch)

rv = func()

Expand Down
2 changes: 2 additions & 0 deletions src/click/_winconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@

if t.TYPE_CHECKING:
try:
# Using `typing_extensions.Buffer` instead of `collections.abc`
# on Windows for some reason does not have `Sized` implemented.
from collections.abc import Buffer # type: ignore
except ImportError:
from typing_extensions import Buffer
Expand Down
12 changes: 9 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ commands = pre-commit run --all-files
[testenv:typing]
deps = -r requirements/typing.txt
commands =
mypy
pyright tests/typing
pyright --verifytypes click --ignoreexternal
mypy --platform linux
mypy --platform darwin
mypy --platform win32
pyright tests/typing --pythonplatform Linux
pyright tests/typing --pythonplatform Darwin
pyright tests/typing --pythonplatform Windows
pyright --verifytypes click --ignoreexternal --pythonplatform Linux
pyright --verifytypes click --ignoreexternal --pythonplatform Darwin
pyright --verifytypes click --ignoreexternal --pythonplatform Windows

[testenv:docs]
deps = -r requirements/docs.txt
Expand Down

0 comments on commit db8be1f

Please sign in to comment.