Skip to content

Commit 34d80c3

Browse files
committed
mypy: Warn about unreachable code
And also fix some types to fix those warnings.
1 parent af80c90 commit 34d80c3

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/matplotlib/_type1font.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@
2121
v1.1, 1993. ISBN 0-201-57044-0.
2222
"""
2323

24+
from __future__ import annotations
25+
2426
import binascii
2527
import functools
2628
import logging
2729
import re
2830
import string
2931
import struct
32+
import typing as T
3033

3134
import numpy as np
3235

@@ -171,7 +174,7 @@ def value(self):
171174
return float(self.raw)
172175

173176

174-
def _tokenize(data: bytes, skip_ws: bool):
177+
def _tokenize(data: bytes, skip_ws: bool) -> T.Generator[_Token, int, None]:
175178
"""
176179
A generator that produces _Token instances from Type-1 font code.
177180
@@ -194,7 +197,7 @@ def _tokenize(data: bytes, skip_ws: bool):
194197
hex_re = re.compile(r'^<[0-9a-fA-F\0\t\r\f\n ]*>$')
195198
oct_re = re.compile(r'[0-7]{1,3}')
196199
pos = 0
197-
next_binary = None
200+
next_binary: int | None = None
198201

199202
while pos < len(text):
200203
if next_binary is not None:

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ exclude = [
227227
# stubtest will import and run, opening a figure if not excluded
228228
".*/tinypages"
229229
]
230+
warn_unreachable = true
230231

231232
[tool.rstcheck]
232233
ignore_directives = [

0 commit comments

Comments
 (0)