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

Restore several removed targets and fields to help with upgrading #10970

Merged
merged 2 commits into from
Oct 15, 2020
Merged
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions src/python/pants/core/deprecated_v1_target_types.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

from typing import Iterable, Optional

from pants.backend.python.target_types import COMMON_PYTHON_FIELDS, PythonInterpreterCompatibility
from pants.engine.addresses import Address
from pants.engine.target import (
COMMON_TARGET_FIELDS,
BoolField,
Dependencies,
InvalidFieldException,
SequenceField,
Sources,
StringField,
Expand Down Expand Up @@ -104,6 +108,14 @@ class BundlesField(SequenceField):
expected_element_type = Bundle
expected_type_description = "an iterable of `bundle` objects"

@classmethod
def compute_value(cls, raw_value: Optional[Iterable[Bundle]], *, address: Address) -> None:
try:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use contextlib.suppress

Copy link
Contributor Author

@Eric-Arellano Eric-Arellano Oct 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, good point. This code is only being added to 2.0.0, though, in a hackily named deprecated_v1_target_types.py file, so I'm not gonna worry about it.

Good to know for the future, though.

super().compute_value(raw_value, address=address)
except InvalidFieldException:
pass
return None


class PythonApp(Target):
alias = "python_app"
Expand Down