hey folks having some trouble writing a rule (in v...
# development
w
hey folks having some trouble writing a rule (in v 1.30), stack trace and rule code in thread
Stack:
Copy code
File "/Users/jerkelens/Projects/datasources/build-support/plugins/goals/deploy_cloud_formation.py", line 24, in <module>
    async def deploy(stack: CloudFormationStack, python_setup: PythonSetup, subprocess_env: SubprocessEncodingEnvironment) -> ProcessResult:
  File "/Users/jerkelens/.cache/pants/setup/bootstrap-Darwin-x86_64/1.30.0_py37/lib/python3.7/site-packages/pants/engine/rules.py", line 423, in rule
    return inner_rule(*args, **kwargs, cacheable=True)
  File "/Users/jerkelens/.cache/pants/setup/bootstrap-Darwin-x86_64/1.30.0_py37/lib/python3.7/site-packages/pants/engine/rules.py", line 413, in inner_rule
    return rule_decorator(*args, **kwargs)
  File "/Users/jerkelens/.cache/pants/setup/bootstrap-Darwin-x86_64/1.30.0_py37/lib/python3.7/site-packages/pants/engine/rules.py", line 397, in rule_decorator
    )(func)
  File "/Users/jerkelens/.cache/pants/setup/bootstrap-Darwin-x86_64/1.30.0_py37/lib/python3.7/site-packages/pants/engine/rules.py", line 270, in wrapper
    rule_visitor.visit(rule_func_node)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 279, in generic_visit
    self.visit(item)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 281, in generic_visit
    self.visit(value)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 281, in generic_visit
    self.visit(value)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/Users/jerkelens/.cache/pants/setup/bootstrap-Darwin-x86_64/1.30.0_py37/lib/python3.7/site-packages/pants/engine/rules.py", line 175, in visit_Call
    self._gets.append(self._extract_constraints(get_descriptor))
  File "/Users/jerkelens/.cache/pants/setup/bootstrap-Darwin-x86_64/1.30.0_py37/lib/python3.7/site-packages/pants/engine/rules.py", line 155, in _extract_constraints
    constructor_type_id = subject_constructor.func.id  # type: ignore[attr-defined]
AttributeError: 'Attribute' object has no attribute 'id'
h
It’s the final await Get(ProcessResult). Add
Process
as the second arg
w
ahhh
got it, would have worked with the
PexProcess
h
Exactly, because you would have been calling the constructor so the AST parser could have figured out the type The error message gets way better in 2.0 for this
a
we were able to remove all the special ast parsing!!! that was so great
h
I don’t think so iirc? We still parse the AST, just added logic for a friendly error message
a
oh hm
i remember. we could remove the ASTTokens 3rdparty library
👍 1
and like tons of code from
rules.py
thanks!
❤️ 1