Skip to content

Commit 5b49dad

Browse files
Basic type checking in all files
1 parent 55564ff commit 5b49dad

File tree

7 files changed

+20
-12
lines changed

7 files changed

+20
-12
lines changed

.github/workflows/lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ jobs:
4242
pip install types-backports types-requests types-setuptools types-toml types-pygments
4343
- name: Check with mypy
4444
# for now only run on a few files to avoid slipping backward
45-
run: mypy bpython/autocomplete.py bpython/args.py bpython/config.py bpython/curtsies.py
45+
run: mypy

bpython/cli.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
import struct
5151
import sys
5252
import time
53-
from typing import Iterator, NoReturn
53+
from typing import Iterator, NoReturn, List
54+
from typing_extensions import Literal
5455
import unicodedata
5556
from dataclasses import dataclass
5657

@@ -144,7 +145,7 @@ def writelines(self, l) -> None:
144145
for s in l:
145146
self.write(s)
146147

147-
def isatty(self) -> True:
148+
def isatty(self) -> Literal[True]:
148149
# some third party (amongst them mercurial) depend on this
149150
return True
150151

@@ -161,7 +162,7 @@ def __init__(self, interface) -> None:
161162

162163
self.encoding = getpreferredencoding()
163164
self.interface = interface
164-
self.buffer = list()
165+
self.buffer: List[str] = list()
165166

166167
def __iter__(self) -> Iterator:
167168
return iter(self.readlines())
@@ -175,7 +176,7 @@ def write(self, value) -> NoReturn:
175176
# others, so here's a hack to keep them happy
176177
raise OSError(errno.EBADF, "sys.stdin is read-only")
177178

178-
def isatty(self) -> True:
179+
def isatty(self) -> Literal[True]:
179180
return True
180181

181182
def readline(self, size=-1):

bpython/test/test_crashers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
from twisted.trial.unittest import TestCase as TrialTestCase
1818
except ImportError:
1919

20-
class TrialTestCase:
20+
class TrialTestCase: # type: ignore [no-redef]
2121
pass
2222

23-
reactor = None
23+
reactor = None # type: ignore
2424

2525
try:
2626
import urwid

bpython/test/test_curtsies_repl.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ def test_last_word(self):
8686
self.assertEqual(curtsiesrepl._last_word("a"), "a")
8787
self.assertEqual(curtsiesrepl._last_word("a b"), "b")
8888

89-
# this is the behavior of bash - not currently implemented
90-
@unittest.skip
89+
@unittest.skip("this is the behavior of bash - not currently implemented")
9190
def test_get_last_word_with_prev_line(self):
9291
self.repl.rl_history.entries = ["1", "2 3", "4 5 6"]
9392
self.repl._set_current_line("abcde")
@@ -300,7 +299,7 @@ def test_simple(self):
300299
self.assertEqual(self.repl.predicted_indent("def asdf():"), 4)
301300
self.assertEqual(self.repl.predicted_indent("def asdf(): return 7"), 0)
302301

303-
@unittest.skip
302+
@unittest.skip("This would be interesting")
304303
def test_complex(self):
305304
self.assertEqual(self.repl.predicted_indent("[a, "), 1)
306305
self.assertEqual(self.repl.predicted_indent("reduce(asdfasdf, "), 7)

bpython/test/test_inspection.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
import sys
33
import unittest
44

5+
from typing import Optional
6+
from types import ModuleType
7+
58
from bpython import inspection
69
from bpython.test.fodder import encoding_ascii
710
from bpython.test.fodder import encoding_latin1
@@ -12,7 +15,7 @@
1215
try:
1316
import numpy
1417
except ImportError:
15-
numpy = None
18+
numpy = None # type: ignore
1619

1720

1821
foo_ascii_only = '''def foo():
@@ -191,7 +194,7 @@ def __mro__(self):
191194
a = 1
192195

193196

194-
member_descriptor = type(Slots.s1)
197+
member_descriptor = type(Slots.s1) # type: ignore
195198

196199

197200
class TestSafeGetAttribute(unittest.TestCase):

bpython/urwid.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
# THE SOFTWARE.
2222

23+
# This whole file typing TODO
24+
# type: ignore
2325

2426
"""bpython backend based on Urwid.
2527

setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,6 @@ files=bpython
7474

7575
[mypy-jedi]
7676
ignore_missing_imports = True
77+
78+
[mypy-urwid]
79+
ignore_missing_imports = True

0 commit comments

Comments
 (0)