https://pantsbuild.org/ logo
#development
Title
# development
w

wonderful-iron-54019

09/11/2020, 8:53 PM
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

hundreds-father-404

09/11/2020, 8:58 PM
It’s the final await Get(ProcessResult). Add
Process
as the second arg
w

wonderful-iron-54019

09/11/2020, 8:58 PM
ahhh
got it, would have worked with the
PexProcess
h

hundreds-father-404

09/11/2020, 8:59 PM
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

aloof-angle-91616

09/11/2020, 9:18 PM
we were able to remove all the special ast parsing!!! that was so great
h

hundreds-father-404

09/11/2020, 9:19 PM
I don’t think so iirc? We still parse the AST, just added logic for a friendly error message
a

aloof-angle-91616

09/11/2020, 9:20 PM
oh hm
i remember. we could remove the ASTTokens 3rdparty library
👍 1
and like tons of code from
rules.py
thanks!
❤️ 1