File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -69,6 +69,9 @@ test = [
6969typecheck = [
7070 " pyright" ,
7171 " typing_extensions" ,
72+ " chardet" ,
73+ " cryptography" ,
74+ " PyOpenSSL" ,
7275]
7376
7477[tool .setuptools ]
Original file line number Diff line number Diff line change 5252 charset_normalizer_version = None
5353
5454try :
55- from chardet import __version__ as chardet_version # type: ignore[import-not-found]
55+ from chardet import __version__ as chardet_version
5656except ImportError :
5757 chardet_version = None
5858
@@ -112,7 +112,7 @@ def _check_cryptography(cryptography_version: str) -> None:
112112try :
113113 check_compatibility (
114114 urllib3 .__version__ , # type: ignore[reportPrivateImportUsage]
115- chardet_version , # type: ignore[reportUnknownArgumentType]
115+ chardet_version ,
116116 charset_normalizer_version ,
117117 )
118118except (AssertionError , ValueError ):
@@ -138,11 +138,11 @@ def _check_cryptography(cryptography_version: str) -> None:
138138 pyopenssl .inject_into_urllib3 ()
139139
140140 # Check cryptography version
141- from cryptography import ( # type: ignore[reportMissingImports]
142- __version__ as cryptography_version , # type: ignore[reportUnknownVariableType]
141+ from cryptography import (
142+ __version__ as cryptography_version ,
143143 )
144144
145- _check_cryptography (cryptography_version ) # type: ignore[reportUnknownArgumentType]
145+ _check_cryptography (cryptography_version )
146146except ImportError :
147147 pass
148148
Original file line number Diff line number Diff line change 1414import importlib
1515import sys
1616from types import ModuleType
17+ from typing import TYPE_CHECKING
1718
1819# -------
1920# urllib3
@@ -46,7 +47,10 @@ def _resolve_char_detection() -> ModuleType | None:
4647 return chardet
4748
4849
49- chardet = _resolve_char_detection ()
50+ if TYPE_CHECKING :
51+ import chardet
52+ else :
53+ chardet = _resolve_char_detection ()
5054
5155# -------
5256# Pythons
Original file line number Diff line number Diff line change 11"""Module containing bug report helper(s)."""
22
3- # pyright: reportUnknownMemberType=false
4-
53import json
64import platform
75import ssl
1917 charset_normalizer = None
2018
2119try :
22- import chardet # type: ignore[import-not-found]
20+ import chardet
2321except ImportError :
2422 chardet = None
2523
3028 OpenSSL = None
3129 cryptography = None
3230else :
33- import cryptography # type: ignore[import-not-found]
34- import OpenSSL # type: ignore[import-not-found]
31+ import cryptography
32+ import OpenSSL
3533
3634
3735def _implementation ():
@@ -51,7 +49,7 @@ def _implementation():
5149 implementation_version = platform .python_version ()
5250 elif implementation == "PyPy" :
5351 pypy = sys .pypy_version_info # type: ignore[attr-defined]
54- implementation_version = f"{ pypy .major } .{ pypy .minor } .{ pypy .micro } "
52+ implementation_version = f"{ pypy .major } .{ pypy .minor } .{ pypy .micro } " # pyright: ignore[reportUnknownMemberType]
5553 if sys .pypy_version_info .releaselevel != "final" : # type: ignore[attr-defined]
5654 implementation_version = "" .join (
5755 [implementation_version , sys .pypy_version_info .releaselevel ] # type: ignore[attr-defined]
Original file line number Diff line number Diff line change @@ -238,7 +238,7 @@ def _encode_files(
238238 fdata = fp
239239 elif isinstance (fp , _SupportsRead ): # type: ignore[reportUnnecessaryIsInstance] # defensive check for untyped callers
240240 fdata = fp .read ()
241- elif fp is None : # type: ignore[reportUnnecessaryComparison] # defensive check for untyped callers
241+ elif fp is None : # defensive check for untyped callers
242242 continue
243243 else :
244244 fdata = fp
@@ -1010,7 +1010,7 @@ def iter_lines(
10101010 ):
10111011 if pending is not None :
10121012 # TODO: remove cast after iter_lines rewrite
1013- chunk = cast ("str | bytes" , pending + chunk ) # type: ignore[operator]
1013+ chunk = cast ("str | bytes" , pending + chunk )
10141014
10151015 if delimiter :
10161016 lines = chunk .split (delimiter ) # type: ignore[arg-type]
You can’t perform that action at this time.
0 commit comments