I was thinking about super-charging `flake8-pantsb...
# development
h
I was thinking about super-charging
flake8-pantsbuild
to do this. I believe it’s possible to have lints like `check that no type hints for a frozen dataclass use
Set
,
FrozenSet
,
List
,
Iterable
, etc`. I love the idea of that living in
flake8-pantsbuild
so that only rule authors use the lints and we don’t hardcode the lints into Pants itself. We can’t catch 100% of the issues, but even if we could automate catching 20%, that would be a big win. This is particularly important as we think about plugin authors starting to write their own rules. They won’t have core Pants committers there to look out for common gotchas in code review
👍 1
cc @aloof-angle-91616 - you might like this idea given the awesome lints you’ve already created for
lint.pythonstyle
and for rules validation
h
I'm not super-familiar with flake8 so I'd be interested in seeing what that lint looks like and how a flake8 lint author would go about writing one
h
It’s based on AST Visitor pattern. You would do something like “check all
ClassDef
nodes, then visit their attribute Nodes and see if their type hints are any of the prohibited values” I’m not sure how ASTVisitor pairs with both type hints and dataclasses. Would be interesting.
👍 1
a
python 3 just has an updated AST that includes type hints and dataclass fields and we just need to check for the right nodes in the visitor
💯 1
h
a
i think this would definitely be possible like eric’s described here
👖 1
🔥 1