Skip to content

Commit 1901784

Browse files
committed
Appease mypy on Windows
1 parent 2abd05a commit 1901784

File tree

4 files changed

+20
-23
lines changed

4 files changed

+20
-23
lines changed

consolekit/__init__.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,13 @@
4141
# pylint: disable=redefined-builtin
4242

4343
# stdlib
44-
import sys
4544
from typing import Any, Callable, Dict, Optional, Type, TypeVar, cast
4645

4746
# 3rd party
4847
import click
4948

5049
# this package
51-
from consolekit import commands, input, terminal_colours, tracebacks, utils # noqa: F401
50+
from consolekit import _readline, commands, input, terminal_colours, tracebacks, utils # noqa: F401
5251
from consolekit.commands import SuggestionGroup
5352
from consolekit.options import _Option
5453

@@ -60,16 +59,6 @@
6059
__version__: str = "1.5.2"
6160
__email__: str = "[email protected]"
6261

63-
if not bool(getattr(sys, "ps1", sys.flags.interactive)): # pragma: no cover
64-
try:
65-
# stdlib
66-
import readline
67-
readline.set_history_length(0)
68-
readline.set_auto_history(False)
69-
except (ImportError, AttributeError):
70-
# Attribute error on PyPy, ImportError on Windows etc.
71-
pass
72-
7362
__all__ = (
7463
"CONTEXT_SETTINGS",
7564
"click_command",

consolekit/_readline.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# pragma: no cover
2+
3+
# stdlib
4+
import sys
5+
6+
if not bool(getattr(sys, "ps1", sys.flags.interactive)):
7+
8+
try:
9+
# stdlib
10+
import readline
11+
12+
# typeshed thinks the module but not these functions are available on Windows.
13+
# In reality the whole module is unavailable.
14+
readline.set_history_length(0)
15+
readline.set_auto_history(False)
16+
except (ImportError, AttributeError):
17+
# Attribute error on PyPy, ImportError on Windows etc.
18+
pass

consolekit/_readline.pyi

Whitespace-only changes.

consolekit/input.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
from click.types import Path, convert_type
6868

6969
# this package
70+
from consolekit import _readline # noqa: F401
7071
from consolekit._types import _ConvertibleType
7172

7273
__all__ = (
@@ -76,17 +77,6 @@
7677
"choice",
7778
)
7879

79-
if not bool(getattr(sys, "ps1", sys.flags.interactive)): # pragma: no cover
80-
81-
try:
82-
# stdlib
83-
import readline
84-
readline.set_history_length(0)
85-
readline.set_auto_history(False)
86-
except (ImportError, AttributeError):
87-
# Attribute error on PyPy, ImportError on Windows etc.
88-
pass
89-
9080

9181
def prompt( # noqa: MAN002
9282
text: str,

0 commit comments

Comments
 (0)