Skip to content

Commit

Permalink
Bump default MyPy to 0.740 (pantsbuild#8358)
Browse files Browse the repository at this point in the history
MyPy released 0.730 and 0.740, bringing these changes: https://mypy-lang.blogspot.com/2019/09/mypy-730-released.html and https://mypy-lang.blogspot.com/2019/10/mypy-0740-released.html

The main changes for the Pants project are:

- "Report undefined module attributes with --ignore-missing-imports", which means our `__init__.py`s now raise errors because of our dynamic runtime import of `pkg_utils`.
   - this requires adding `type: ignore` to all uses of `__import__("pkg_resources").declare_namespace(__name__)`
  - Alternatively, we could use `import pkg_resources; pkg_resources.declare_namespace(__name__)`, but this keeps `pkg_resources` as a registered symbol, which we want to avoid.
- `# type: ignore` can now only ignore specific error codes
- location of some errors now more precise
- type check `str.format()`
- prettier and more explicit error messages
  • Loading branch information
Eric-Arellano authored Nov 26, 2019
1 parent f2a3526 commit 56406d3
Show file tree
Hide file tree
Showing 104 changed files with 147 additions and 134 deletions.
3 changes: 3 additions & 0 deletions build-support/bin/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ python_binary(
python_binary(
name = 'mypy',
source = 'mypy.py',
dependencies = [
':common',
],
tags = {'type_checked'},
)

Expand Down
2 changes: 1 addition & 1 deletion build-support/bin/check_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bad_files=()
for package_file in ${non_empty_files}
do
if [[ "$(sed -E -e 's/^[[:space:]]+//' -e 's/[[:space:]]+$//' "${package_file}")" != \
'__import__("pkg_resources").declare_namespace(__name__)' ]]
'__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]' ]]
then
bad_files+=("${package_file}")
fi
Expand Down
8 changes: 4 additions & 4 deletions build-support/bin/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ def pants_command(
shard: Optional[str] = None,
oauth_token_path: Optional[str] = None
) -> List[str]:
if self == self.v2_remote and oauth_token_path is None: # type: ignore
if self == self.v2_remote and oauth_token_path is None: # type: ignore[comparison-overlap] # issues with understanding `self`
raise ValueError("Must specify oauth_token_path.")
result: List[str] = { # type: ignore
result = {
self.v1_no_chroot: ["./pants.pex", "test.pytest", "--no-chroot", *sorted(targets), *PYTEST_PASSTHRU_ARGS],
self.v1_chroot: ["./pants.pex", "test.pytest", *sorted(targets), *PYTEST_PASSTHRU_ARGS],
self.v2_local: ["./pants.pex", "--no-v1", "--v2", "test", *sorted(targets)],
Expand All @@ -227,8 +227,8 @@ def pants_command(
"test",
*sorted(targets),
]
}[self]
if shard is not None and self in [self.v1_no_chroot, self.v1_chroot]: # type: ignore
}[self] # type: ignore[index] # issues with understanding `self`
if shard is not None and self in [self.v1_no_chroot, self.v1_chroot]: # type: ignore[comparison-overlap] # issues with understanding `self`
result.insert(2, f"--test-pytest-test-shard={shard}")
return result

Expand Down
10 changes: 8 additions & 2 deletions build-support/mypy/mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
# because our codebase has so little type coverage. As we add more types, these options should be
# re-evaluated and made more strict where possible.

new_semantic_analyzer = True

# Optionals
no_implicit_optional = True

Expand All @@ -29,6 +27,8 @@ disallow_any_generics = False
disallow_subclassing_any = False

# Strictness
allow_untyped_globals = False
allow_redefinition = False
implicit_reexport = False
strict_equality = True

Expand All @@ -37,10 +37,16 @@ warn_unused_ignores = True
warn_no_return = True
warn_return_any = True
warn_redundant_casts = True
warn_unreachable = True

# Error output
show_column_numbers = True
show_error_context = True
show_error_codes = True
show_traceback = True
pretty = True
color_output = True
error_summary = True

# Imports. See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports.
ignore_missing_imports = True
Expand Down
2 changes: 1 addition & 1 deletion contrib/avro/src/python/pants/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/avro/src/python/pants/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/avro/src/python/pants/contrib/avro/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/awslambda/python/src/python/pants/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/buildgen/src/python/pants/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/buildgen/src/python/pants/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/buildgen/tests/python/pants_test/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/buildrefactor/src/python/pants/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/buildrefactor/src/python/pants/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/buildrefactor/tests/python/pants_test/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/codeanalysis/src/python/pants/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/codeanalysis/src/python/pants/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/confluence/src/python/pants/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/confluence/src/python/pants/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/cpp/src/python/pants/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/cpp/src/python/pants/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/cpp/tests/python/pants_test/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/cpp/tests/python/pants_test/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/errorprone/src/python/pants/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/errorprone/src/python/pants/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/findbugs/src/python/pants/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/findbugs/src/python/pants/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/findbugs/tests/python/pants_test/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/go/src/python/pants/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/go/src/python/pants/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/go/tests/python/pants_test/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/go/tests/python/pants_test/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/googlejavaformat/src/python/pants/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/jax_ws/src/python/pants/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/jax_ws/src/python/pants/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/jax_ws/tests/python/pants_test/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/jax_ws/tests/python/pants_test/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/mypy/src/python/pants/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/mypy/src/python/pants/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/mypy/src/python/pants/contrib/mypy/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
4 changes: 2 additions & 2 deletions contrib/mypy/src/python/pants/contrib/mypy/tasks/mypy_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def prepare(cls, options, round_manager):

@classmethod
def register_options(cls, register):
register('--mypy-version', default='0.720', help='The version of mypy to use.',
register('--mypy-version', default='0.740', help='The version of mypy to use.',
removal_version='1.24.0.dev1', removal_hint='Use --version instead.')
register('--version', default='0.720', help='The version of mypy to use.')
register('--version', default='0.740', help='The version of mypy to use.')
register('--include-requirements', type=bool, default=False,
help='Whether to include the transitive requirements of targets being checked. This is'
'useful if those targets depend on mypy plugins or distributions that provide '
Expand Down
2 changes: 1 addition & 1 deletion contrib/mypy/tests/python/pants_test/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/mypy/tests/python/pants_test/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/node/src/python/pants/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/node/src/python/pants/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/node/tests/python/pants_test/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/node/tests/python/pants_test/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/python/src/python/pants/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/python/src/python/pants/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/python/src/python/pants/contrib/python/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/python/tests/python/pants_test/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/python/tests/python/pants_test/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/scalajs/src/python/pants/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/scalajs/src/python/pants/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/scalajs/tests/python/pants_test/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/scrooge/src/python/pants/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/scrooge/src/python/pants/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/scrooge/tests/python/pants_test/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/thrifty/src/python/pants/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion contrib/thrifty/src/python/pants/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion src/python/pants/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
2 changes: 1 addition & 1 deletion src/python/pants/backend/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__("pkg_resources").declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def _prepare_inits(self) -> Set[str]:
missing_init_files = identify_missing_init_files(sources)
if missing_init_files:
with temporary_file(permissions=0o644) as ns_package:
ns_package.write(b'__import__("pkg_resources").declare_namespace(__name__)')
ns_package.write(b'__import__("pkg_resources").declare_namespace(__name__) # type: ignore[attr-defined]')
ns_package.flush()
for missing_init_file in missing_init_files:
self._builder.add_source(filename=ns_package.name, env_filename=missing_init_file)
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/binaries/executable_pex_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class ExecutablePexTool(Subsystem):

entry_point = None
entry_point: Optional[str] = None

base_requirements: List['PythonRequirement'] = []

Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/build_graph/aliased_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def expand(self, name=None, target=None, **kwargs):
:param string target: The address of the destination target.
"""
if name is None:
raise TargetDefinitionException('{}:?'.format(self._parse_context.rel_path, name),
raise TargetDefinitionException('{}:?'.format(self._parse_context.rel_path),
'The alias() must have a name!')
if target is None:
raise TargetDefinitionException('{}:{}'.format(self._parse_context.rel_path, name),
Expand Down
4 changes: 2 additions & 2 deletions src/python/pants/build_graph/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ def compute_injectable_specs(cls, kwargs=None, payload=None):
# N.B. This pattern turns this method into a non-yielding generator, which is helpful for
# subclassing.
return
yield
yield # type: ignore[misc] # MyPy doesn't understand this pattern; complains that code is unreachable

@classmethod
def compute_dependency_specs(cls, kwargs=None, payload=None):
Expand All @@ -643,7 +643,7 @@ def compute_dependency_specs(cls, kwargs=None, payload=None):
# N.B. This pattern turns this method into a non-yielding generator, which is helpful for
# subclassing.
return
yield
yield # type: ignore[misc] # MyPy doesn't understand this pattern; complains that code is unreachable

@property
def dependencies(self):
Expand Down
4 changes: 0 additions & 4 deletions src/python/pants/engine/addressable.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ def _checked_value(self, instance, value):
.format(self._name, instance),
e)

return value

def _resolve_value(self, instance, value):
if not isinstance(value, Resolvable):
# The value is concrete which means we type-checked on set so no need to do so again, its a
Expand All @@ -208,8 +206,6 @@ def _resolve_value(self, instance, value):
.format(value.address, self._name, instance),
e)

return resolved_value


def _addressable_wrapper(addressable_descriptor, type_constraint):
def wrapper(func):
Expand Down
3 changes: 1 addition & 2 deletions src/python/pants/engine/goal.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
from pants.util.meta import classproperty


@dataclass(frozen=True)
# type: ignore # tracked by https://github.com/python/mypy/issues/5374, which they put as high priority.
@dataclass(frozen=True) # type: ignore[misc] # tracked by https://github.com/python/mypy/issues/5374, which they put as high priority.
class Goal(metaclass=ABCMeta):
"""The named product of a `@console_rule`.
Expand Down
Loading

0 comments on commit 56406d3

Please sign in to comment.