Skip to content

Commit

Permalink
rename uncacheable -> side_effecting
Browse files Browse the repository at this point in the history
  • Loading branch information
gshuflin committed Jan 11, 2020
1 parent 50860c7 commit e7d4498
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/python/pants/engine/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def write(self, payload):

class Console:
"""Class responsible for writing text to the console while Pants is running. """
uncacheable = True
side_effecting = True

def __init__(self, stdout=None, stderr=None, use_colors: bool = True, session: Optional[Any] = None):
"""`stdout` and `stderr` may be explicitly provided when Console is constructed.
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/engine/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class UrlToFetch:
@dataclass(frozen=True)
class Workspace:
"""Abstract handle for operations that touch the real local filesystem."""
uncacheable = True
side_effecting = True
_scheduler: "SchedulerSession"

def materialize_directory(
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/engine/interactive_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __post_init__(self):
@dataclass(frozen=True)
class InteractiveRunner:
_scheduler: 'SchedulerSession'
uncacheable = True
side_effecting = True

def run_local_interactive_process(self, request: InteractiveProcessRequest) -> InteractiveProcessResult:
ExceptionSink.toggle_ignoring_sigint_v2_engine(True)
Expand Down
4 changes: 2 additions & 2 deletions src/python/pants/engine/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ def rule_decorator(*args, **kwargs) -> Callable:
def validate_parameter_types(func_id: str, parameter_types: Tuple[Type, ...], cacheable: bool) -> None:
if cacheable:
for ty in parameter_types:
if getattr(ty, "uncacheable", False):
raise ValueError(f"Non-console `@rule` {func_id} has an uncacheable parameter: {ty}")
if getattr(ty, "side_effecting", False):
raise ValueError(f"Non-console `@rule` {func_id} has a side-effecting parameter: {ty}")


def inner_rule(*args, **kwargs) -> Callable:
Expand Down
8 changes: 4 additions & 4 deletions tests/python/pants_test/engine/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@ async def a_goal_rule_generator(console: Console) -> Example:


class RuleTest(TestBase):
def test_run_rule_console_rule_generator(self):
def test_run_rule_goal_rule_generator(self):
res = run_rule(
a_goal_rule_generator,
rule_args=[Console()],
mock_gets=[MockGet(product_type=A, subject_type=str, mock=lambda _: A())],
)
self.assertEquals(res, Example(0))

def test_uncacheable_inputs(self) -> None:
@console_rule
def test_side_effecting_inputs(self) -> None:
@goal_rule
def valid_rule(console: Console, b: str) -> Example:
return Example(exit_code=0)

Expand All @@ -106,7 +106,7 @@ def invalid_rule(console: Console, b: str) -> bool:
return False

error_str = str(cm.exception)
assert "invalid_rule has an uncacheable parameter" in error_str
assert "invalid_rule has a side-effecting parameter" in error_str
assert "pants.engine.console.Console" in error_str


Expand Down

0 comments on commit e7d4498

Please sign in to comment.