Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5b49dad

Browse files
Basic type checking in all files
1 parent55564ff commit5b49dad

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
importstruct
5151
importsys
5252
importtime
53-
fromtypingimportIterator,NoReturn
53+
fromtypingimportIterator,NoReturn,List
54+
fromtyping_extensionsimportLiteral
5455
importunicodedata
5556
fromdataclassesimportdataclass
5657

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

147-
defisatty(self)->True:
148+
defisatty(self)->Literal[True]:
148149
# some third party (amongst them mercurial) depend on this
149150
returnTrue
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
returniter(self.readlines())
@@ -175,7 +176,7 @@ def write(self, value) -> NoReturn:
175176
# others, so here's a hack to keep them happy
176177
raiseOSError(errno.EBADF,"sys.stdin is read-only")
177178

178-
defisatty(self)->True:
179+
defisatty(self)->Literal[True]:
179180
returnTrue
180181

181182
defreadline(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
fromtwisted.trial.unittestimportTestCaseasTrialTestCase
1818
exceptImportError:
1919

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

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

2525
try:
2626
importurwid

‎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
deftest_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
deftest_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
importsys
33
importunittest
44

5+
fromtypingimportOptional
6+
fromtypesimportModuleType
7+
58
frombpythonimportinspection
69
frombpython.test.fodderimportencoding_ascii
710
frombpython.test.fodderimportencoding_latin1
@@ -12,7 +15,7 @@
1215
try:
1316
importnumpy
1417
exceptImportError:
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
classTestSafeGetAttribute(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)

[8]ページ先頭

©2009-2025 Movatter.jp