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

Deprecate sources except EagerFilesetWithSpec #5993

Merged
Merged
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
19 changes: 18 additions & 1 deletion src/python/pants/build_graph/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from pants.build_graph.target_scopes import Scope
from pants.fs.fs import safe_filename
from pants.source.payload_fields import SourcesField
from pants.source.wrapped_globs import Files, FilesetWithSpec, Globs
from pants.source.wrapped_globs import EagerFilesetWithSpec, Files, FilesetWithSpec, Globs
from pants.subsystem.subsystem import Subsystem
from pants.util.memo import memoized_property

Expand Down Expand Up @@ -881,10 +881,27 @@ def create_sources_field(self, sources, sources_rel_path, key_arg=None):
sources = FilesetWithSpec.empty(sources_rel_path)
elif isinstance(sources, (set, list, tuple)):
# Received a literal sources list: convert to a FilesetWithSpec via Files.
deprecated_conditional(
lambda: True,
'1.10.0.dev0',
('Passing collections as the value of the sources argument to create_sources_field is '
'deprecated, and now takes a slow path. Instead, class {} should have its sources '
'argument populated by the engine, either by using the standard parsing pipeline, or by '
'requesting a SourcesField product.'
'the v2 engine.').format(self.__class__.__name__)
)
sources = Files.create_fileset_with_spec(sources_rel_path, *sources)
elif not isinstance(sources, FilesetWithSpec):
key_arg_section = "'{}' to be ".format(key_arg) if key_arg else ""
raise TargetDefinitionException(self, "Expected {}a glob, an address or a list, but was {}"
.format(key_arg_section, type(sources)))
elif not isinstance(sources, EagerFilesetWithSpec):
deprecated_conditional(
lambda: True,
'1.10.0.dev0',
('FilesetWithSpec sources values are deprecated except for EagerFilesetWithSpec values. '
'Saw value of type {}').format(type(sources))
)


return SourcesField(sources=sources)