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

Partially type check help, ivy, task, and backend target and subsystem folders #8635

Merged
merged 6 commits into from
Nov 18, 2019
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 src/python/pants/backend/codegen/thrift/java/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ python_library(
'src/python/pants/subsystem',
'src/python/pants/task',
],
tags = {"partially_type_checked"},
)
1 change: 1 addition & 0 deletions src/python/pants/backend/codegen/thrift/lib/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ python_library(
'src/python/pants/task',
'src/python/pants/util:memo',
],
tags = {"partially_type_checked"},
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import re
import shutil
import subprocess
from typing import Optional

from twitter.common.collections import OrderedSet

Expand All @@ -20,7 +21,7 @@
class ApacheThriftGenBase(SimpleCodegenTask):
# The name of the thrift generator to use. Subclasses must set.
# E.g., java, py (see `thrift -help` for all available generators).
thrift_generator = None
thrift_generator: Optional[str] = None

# Subclasses may set their own default generator options.
default_gen_options_map = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ class ClocBinary(Script):

replaces_scope = 'cloc'
replaces_name = 'version'

9 changes: 6 additions & 3 deletions src/python/pants/backend/jvm/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ python_library(
dependencies=[
'src/python/pants/util:contextutil',
'src/python/pants/util:dirutil',
]
],
tags = {"partially_type_checked"},
)

python_library(
Expand All @@ -18,6 +19,7 @@ python_library(
'src/python/pants/base:hash_utils',
'src/python/pants/base:payload_field',
],
tags = {"partially_type_checked"},
)

python_library(
Expand Down Expand Up @@ -59,6 +61,7 @@ python_library(
'src/python/pants/util:dirutil',
'src/python/pants/util:fileutil',
],
tags = {"partially_type_checked"},
)

resources(
Expand All @@ -69,8 +72,7 @@ resources(
python_library(
name='repository',
sources=['repository.py'],
dependencies = [
]
tags = {"partially_type_checked"},
)

python_library(
Expand All @@ -90,4 +92,5 @@ python_library(
':artifact',
'src/python/pants/base:validation',
],
tags = {"partially_type_checked"},
)
2 changes: 1 addition & 1 deletion src/python/pants/backend/jvm/ivy_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ def _exec_ivy(cls, ivy, confs, ivyxml, args, jvm_options, executor,

runner = ivy.runner(jvm_options=ivy_jvm_options, args=ivy_args, executor=executor)
try:
with ivy.resolution_lock:
with ivy.resolution_lock():
result = execute_runner(runner, workunit_factory=workunit_factory,
workunit_name=workunit_name)
if result != 0:
Expand Down
14 changes: 12 additions & 2 deletions src/python/pants/backend/jvm/subsystems/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ python_library(
'src/python/pants/java/distribution',
'src/python/pants/option',
],
tags = {"partially_type_checked"},
)

python_library(
Expand All @@ -34,6 +35,7 @@ python_library(
'src/python/pants/option',
'src/python/pants/subsystem',
],
tags = {"partially_type_checked"},
)

python_library(
Expand All @@ -46,6 +48,7 @@ python_library(
'src/python/pants/option',
'src/python/pants/subsystem',
],
tags = {"partially_type_checked"},
)

python_library(
Expand All @@ -59,6 +62,7 @@ python_library(
'src/python/pants/build_graph',
'src/python/pants/subsystem',
],
tags = {"partially_type_checked"},
)

python_library(
Expand All @@ -69,6 +73,7 @@ python_library(
'src/python/pants/subsystem',
'src/python/pants/util:strutil',
],
tags = {"partially_type_checked"},
)

python_library(
Expand All @@ -82,6 +87,7 @@ python_library(
'src/python/pants/util:memo',
'src/python/pants/java/distribution',
],
tags = {"partially_type_checked"},
)

python_library(
Expand Down Expand Up @@ -109,6 +115,7 @@ python_library(
'src/python/pants/backend/jvm/targets:jvm',
'src/python/pants/util:memo',
],
tags = {"partially_type_checked"},
)

python_library(
Expand All @@ -120,6 +127,7 @@ python_library(
'src/python/pants/java/jar',
'src/python/pants/backend/jvm/targets:jvm',
],
tags = {"partially_type_checked"},
)

python_library(
Expand All @@ -133,7 +141,8 @@ python_library(
'src/python/pants/java/jar',
'src/python/pants/subsystem',
'src/python/pants/util:contextutil',
]
],
tags = {"partially_type_checked"},
)

python_library(
Expand All @@ -154,7 +163,8 @@ python_library(
dependencies = [
'src/python/pants/build_graph',
'src/python/pants/subsystem',
]
],
tags = {"partially_type_checked"},
)

python_library(
Expand Down
12 changes: 5 additions & 7 deletions src/python/pants/backend/jvm/subsystems/jvm_tool_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from collections import namedtuple
from textwrap import dedent
from typing import List

from pants.base.exceptions import TaskError
from pants.java.distribution.distribution import DistributionLocator
Expand Down Expand Up @@ -46,7 +47,7 @@ def is_default(self, options):
"""
return options.for_scope(self.scope).is_default(self.key.replace('-', '_'))

_jvm_tools = [] # List of JvmTool objects.
_jvm_tools: List[JvmTool] = []

@classmethod
def subsystem_dependencies(cls):
Expand Down Expand Up @@ -147,15 +148,12 @@ def prepare_tools(cls, round_manager):
round_manager.require_data('jvm_build_tools_classpath_callbacks')

@staticmethod
def get_registered_tools():
"""Returns all registered jvm tools.

:rtype: list of :class:`JvmToolMixin.JvmTool`
"""
def get_registered_tools() -> List["JvmTool"]:
"""Returns all registered jvm tools."""
return JvmToolMixin._jvm_tools

@staticmethod
def reset_registered_tools():
def reset_registered_tools() -> None:
"""Needed only for test isolation."""
JvmToolMixin._jvm_tools = []

Expand Down
3 changes: 3 additions & 0 deletions src/python/pants/backend/jvm/targets/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ python_library(
'src/python/pants/util:netrc',
'src/python/pants/util:objects',
],
tags = {"partially_type_checked"},
)

python_library(
Expand All @@ -64,6 +65,7 @@ python_library(
'src/python/pants/base:exceptions',
'src/python/pants/build_graph',
],
tags = {"partially_type_checked"},
)

python_library(
Expand All @@ -85,4 +87,5 @@ python_library(
'src/python/pants/build_graph',
'src/python/pants/util:memo',
],
tags = {"partially_type_checked"},
)
10 changes: 6 additions & 4 deletions src/python/pants/backend/jvm/targets/jvm_prep_command.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

from typing import FrozenSet

from pants.backend.jvm.targets.jvm_target import JvmTarget
from pants.base.exceptions import TargetDefinitionException
from pants.base.payload import Payload
Expand Down Expand Up @@ -34,20 +36,20 @@ class JvmPrepCommand(JvmTarget):

:API: public
"""
_goals=frozenset()
_goals: FrozenSet[str] = frozenset()

@staticmethod
def add_goal(goal):
"""Add a named goal to the list of valid goals for the 'goal' parameter."""
JvmPrepCommand._goals = frozenset(list(JvmPrepCommand._goals) + [goal])

@classmethod
def reset(cls):
def reset(cls) -> None:
"""Used for testing purposes to reset state."""
cls._goals=frozenset()
cls._goals = frozenset()

@staticmethod
def goals():
def goals() -> FrozenSet[str]:
return JvmPrepCommand._goals

def __init__(self, payload=None, mainclass=None, args=None, jvm_options=None, goal=None,
Expand Down
5 changes: 5 additions & 0 deletions src/python/pants/backend/jvm/tasks/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ python_library(
python_library(
name = 'classpath_entry',
sources = ['classpath_entry.py'],
tags = {"partially_type_checked"},
)

python_library(
Expand All @@ -177,6 +178,7 @@ python_library(
'src/python/pants/util:dirutil',
'src/python/pants/util:strutil',
],
tags = {"partially_type_checked"},
)

python_library(
Expand All @@ -193,6 +195,7 @@ python_library(
'src/python/pants/goal:products',
'src/python/pants/util:dirutil',
],
tags = {"partially_type_checked"},
)

python_library(
Expand Down Expand Up @@ -517,6 +520,7 @@ python_library(
'src/python/pants/base:exceptions',
'src/python/pants/task',
],
tags = {"partially_type_checked"},
)

python_library(
Expand Down Expand Up @@ -547,6 +551,7 @@ python_library(
'src/python/pants/process',
'src/python/pants/task',
],
tags = {"partially_type_checked"},
)

python_library(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def get_external_url_generator(self):
class CoursierUrlGenerator(BinaryToolUrlGenerator):

def __init__(self, template_urls):
super(CoursierUrlGenerator, self).__init__()
super().__init__()
self._template_urls = template_urls

def generate_urls(self, version, host_platform):
Expand Down
1 change: 1 addition & 0 deletions src/python/pants/backend/native/config/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ python_library(
'src/python/pants/engine:platform',
'src/python/pants/util:osutil',
],
tags = {"partially_type_checked"},
)
10 changes: 5 additions & 5 deletions src/python/pants/backend/native/config/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def _single_list_field_operation(self, field_name, list_value, prepend=True):
cur_value = getattr(self, field_name)

if prepend:
new_value = list_value + cur_value
new_value = tuple(list_value) + tuple(cur_value)
else:
new_value = cur_value + list_value
new_value = tuple(cur_value) + tuple(list_value)

arg_dict = {field_name: new_value}
return self.copy(**arg_dict)
Expand Down Expand Up @@ -93,7 +93,7 @@ def sequence(self, other, exclude_list_fields=None):
for list_field_name in shared_list_fields:
lhs_value = getattr(self, list_field_name)
rhs_value = getattr(other, list_field_name)
overwrite_kwargs[list_field_name] = lhs_value + rhs_value
overwrite_kwargs[list_field_name] = tuple(lhs_value) + tuple(rhs_value)

return self.copy(**overwrite_kwargs)

Expand Down Expand Up @@ -187,7 +187,7 @@ class Assembler(_AlgebraicDataclass, _Executable):
path_entries: Tuple[str, ...]
exe_filename: str
runtime_library_dirs: Tuple[str, ...]
extra_args: Tuple[str]
extra_args: Tuple[str, ...]


class _LinkerMixin(_Executable):
Expand All @@ -212,7 +212,7 @@ def extra_object_files(self):
def invocation_environment_dict(self):
ret = super(_LinkerMixin, self).invocation_environment_dict.copy()

full_library_path_dirs = self.linking_library_dirs + [
full_library_path_dirs = list(self.linking_library_dirs) + [
os.path.dirname(f) for f in self.extra_object_files
]

Expand Down
1 change: 1 addition & 0 deletions src/python/pants/backend/native/subsystems/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ python_library(
'src/python/pants/backend/native/subsystems/utils',
'src/python/pants/build_graph',
'src/python/pants/engine:rules',
'src/python/pants/engine:platform',
'src/python/pants/engine:selectors',
'src/python/pants/subsystem',
'src/python/pants/util:collections',
Expand Down
2 changes: 2 additions & 0 deletions src/python/pants/backend/native/subsystems/binaries/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ python_library(
'src/python/pants/backend/native/subsystems/utils',
'src/python/pants/binaries',
'src/python/pants/engine:rules',
'src/python/pants/engine:platform',
'src/python/pants/util:dirutil',
'src/python/pants/util:memo',
],
tags = {"partially_type_checked"},
)
Loading