Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove obsolete "# type: ignore" comments #9340

Merged
merged 1 commit into from
Dec 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ follow_imports = silent
ignore_missing_imports = True
disallow_untyped_defs = True
disallow_any_generics = True
warn_unused_ignores = True

[mypy-pip/_vendor/*]
follow_imports = skip
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/cli/main_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def parse_command(args):

# --version
if general_options.version:
sys.stdout.write(parser.version) # type: ignore
sys.stdout.write(parser.version)
sys.stdout.write(os.linesep)
sys.exit()

Expand Down
15 changes: 2 additions & 13 deletions src/pip/_internal/commands/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@ def show_value(name, value):
def show_sys_implementation():
# type: () -> None
logger.info('sys.implementation:')
if hasattr(sys, 'implementation'):
implementation = sys.implementation # type: ignore
implementation_name = implementation.name
else:
implementation_name = ''

implementation_name = sys.implementation.name
with indent_log():
show_value('name', implementation_name)

Expand Down Expand Up @@ -88,13 +83,7 @@ def get_vendor_version_from_module(module_name):

if not version:
# Try to find version in debundled module info
# The type for module.__file__ is Optional[str] in
# Python 2, and str in Python 3. The type: ignore is
# added to account for Python 2, instead of a cast
# and should be removed once we drop Python 2 support
pkg_set = pkg_resources.WorkingSet(
[os.path.dirname(module.__file__)] # type: ignore
)
pkg_set = pkg_resources.WorkingSet([os.path.dirname(module.__file__)])
package = pkg_set.find(pkg_resources.Requirement.parse(module_name))
version = getattr(package, 'version', None)

Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/operations/install/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ def rehash(path, blocksize=1 << 20):
digest = 'sha256=' + urlsafe_b64encode(
h.digest()
).decode('latin1').rstrip('=')
# unicode/str python2 issues
return (digest, str(length)) # type: ignore
return (digest, str(length))


def csv_io_kwargs(mode):
Expand Down
6 changes: 2 additions & 4 deletions src/pip/_internal/req/req_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,7 @@ def parse_line(line):

args_str, options_str = break_args_options(line)

# https://github.com/python/mypy/issues/1174
opts, _ = parser.parse_args(
shlex.split(options_str), defaults) # type: ignore
opts, _ = parser.parse_args(shlex.split(options_str), defaults)
jdufresne marked this conversation as resolved.
Show resolved Hide resolved

return args_str, opts

Expand All @@ -433,7 +431,7 @@ def break_args_options(line):
else:
args.append(token)
options.pop(0)
return ' '.join(args), ' '.join(options) # type: ignore
return ' '.join(args), ' '.join(options)


class OptionParsingError(Exception):
Expand Down
6 changes: 2 additions & 4 deletions src/pip/_internal/utils/unpacking.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ def untar_file(filename, location):
for member in tar.getmembers():
fn = member.name
if leading:
# https://github.com/python/mypy/issues/1174
fn = split_leading_dir(fn)[1] # type: ignore
fn = split_leading_dir(fn)[1]
path = os.path.join(location, fn)
if not is_within_directory(location, path):
message = (
Expand Down Expand Up @@ -234,8 +233,7 @@ def untar_file(filename, location):
shutil.copyfileobj(fp, destfp)
fp.close()
# Update the timestamp (useful for cython compiled files)
# https://github.com/python/typeshed/issues/2673
tar.utime(member, path) # type: ignore
tar.utime(member, path)
# member have any execute permissions for user/group/world?
if member.mode & 0o111:
set_extracted_file_to_default_mode_plus_executable(path)
Expand Down