-
-
Notifications
You must be signed in to change notification settings - Fork 644
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
hygienic BUILD file modifications (like buildozer) with libCST #9434
Closed
cosmicexplorer
wants to merge
1
commit into
pantsbuild:main
from
cosmicexplorer:libcst-build-file-rewrites
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,11 @@ | |
from abc import ABC, abstractmethod | ||
from collections import namedtuple | ||
from collections.abc import Iterable | ||
from typing import Generic, Iterator, TypeVar | ||
from dataclasses import dataclass | ||
from typing import Dict, Generic, Iterator, Tuple, TypeVar | ||
|
||
from pants.util.meta import decorated_type_checkable | ||
from pants.util.memo import memoized_property | ||
from pants.util.meta import decorated_type_checkable, frozen_after_init | ||
|
||
|
||
class SerializationError(Exception): | ||
|
@@ -213,3 +215,29 @@ def non_member_error_message(subject): | |
return union.define_instance_of( | ||
cls, non_member_error_message=staticmethod(non_member_error_message) | ||
) | ||
|
||
|
||
_K = TypeVar("_K") | ||
_V = TypeVar("_V") | ||
|
||
|
||
@frozen_after_init | ||
@dataclass(unsafe_hash=True) | ||
class HashableDict(Generic[_K, _V]): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See FrozenDict from Pants.util.frozendict. I think it does what you’re after here. |
||
_tuple_mapping: Tuple[Tuple[_K, _V], ...] | ||
|
||
def __init__(self, mapping: Dict[_K, _V]) -> None: | ||
self._tuple_mapping = tuple(mapping.items()) | ||
|
||
def keys(self) -> Iterable: | ||
return tuple(entry[0] for entry in self._tuple_mapping) | ||
|
||
def values(self) -> Iterable: | ||
return tuple(entry[1] for entry in self._tuple_mapping) | ||
|
||
def items(self) -> Tuple[Tuple[_K, _V], ...]: | ||
return self._tuple_mapping | ||
|
||
@memoized_property | ||
def as_dict(self) -> Dict[_K, _V]: | ||
return dict(self._tuple_mapping) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
python_library( | ||
dependencies=[ | ||
'3rdparty/python:dataclasses', | ||
'3rdparty/python:libcst', | ||
'src/python/pants/engine:goal', | ||
'src/python/pants/engine:rules', | ||
], | ||
tags={'partially_type_checked'}, | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this is all dead code. It was dead code before this PR, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please break this out into a dedicated PR?
This change looks incredible, although the size of the diff makes it a little overwhelming to review. It’d be hugely helpful to break out any possible prework PRs like this so that this PR is smaller.