-
-
Notifications
You must be signed in to change notification settings - Fork 652
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
Mark certain types as "side-effecting" #8922
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5c0c2e1
Mark certain types as console-rule-only
gshuflin 188cd5e
Rename side_effecting -> uncacheable
gshuflin 22601f7
Fix return type
gshuflin 37eca64
Make InteractiveRunner only used in @console_rule
gshuflin 50860c7
Fix test_test.py
gshuflin e7d4498
rename uncacheable -> side_effecting
gshuflin 71ed47e
Use a class annotation to mark side_effecting
gshuflin 34e4854
Fix order
gshuflin 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
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 |
---|---|---|
|
@@ -86,7 +86,7 @@ async def a_goal_rule_generator(console: Console) -> Example: | |
return Example(exit_code=0) | ||
|
||
|
||
class RuleTest(unittest.TestCase): | ||
class RuleTest(TestBase): | ||
def test_run_rule_goal_rule_generator(self): | ||
res = run_rule( | ||
a_goal_rule_generator, | ||
|
@@ -95,6 +95,20 @@ def test_run_rule_goal_rule_generator(self): | |
) | ||
self.assertEquals(res, Example(0)) | ||
|
||
def test_side_effecting_inputs(self) -> None: | ||
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. Thanks for the type hint :) |
||
@goal_rule | ||
def valid_rule(console: Console, b: str) -> Example: | ||
return Example(exit_code=0) | ||
|
||
with self.assertRaises(ValueError) as cm: | ||
@rule | ||
def invalid_rule(console: Console, b: str) -> bool: | ||
return False | ||
|
||
error_str = str(cm.exception) | ||
assert "invalid_rule has a side-effecting parameter" in error_str | ||
assert "pants.engine.console.Console" in error_str | ||
|
||
|
||
class RuleIndexTest(TestBase): | ||
def test_creation_fails_with_bad_declaration_type(self): | ||
|
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.
Good change.