ruff icon indicating copy to clipboard operation
ruff copied to clipboard

[redknot] add module type and attribute lookup for some types

Open plredmond opened this issue 1 year ago • 2 comments
trafficstars

  • Add a module type, ModuleTypeId
  • Add an attribute lookup method get_member for Type
    • Only implemented for ModuleTypeId and ClassTypeId
    • [ ] Should this be a trait?
    • [ ] Uses unwrap, but we should remove that. Maybe add a new variant to QueryError?
  • Add infer_definition_type case for Import
  • Add infer_expr_type case for Attribute
  • Add a test to exercise these
  • [ ] remove all NOTE/FIXME/TODO after discussing with reviewers

plredmond avatar May 14 '24 00:05 plredmond

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

github-actions[bot] avatar May 14 '24 01:05 github-actions[bot]

Since you folks were ooo, I added questions that I had as NOTE/TODO/FIXME comments in the diff.

plredmond avatar May 24 '24 21:05 plredmond

Thanks for your review. I've made requested changes and asked some questions to describe the follow-up work in comments. Let me know when/if it's ok to merge.

plredmond avatar May 28 '24 17:05 plredmond

Oh there are a couple clippy issues to fix, too.

Looks like you could easily support AnnotatedAssignment the same as Assignment for now (with a TODO to actually look at the annotation) and our Definition handling would cover all variants?

carljm avatar May 28 '24 17:05 carljm

  • Clippy: rename an unused variable which we'll use after completing the get_member case for unions
  • Added case to infer_definition_type for AnnotatedAssignment variant which returns Type::Unknown when the value isn't present; includes a TODO to look at the annotation (which presumably will have a type expression)

plredmond avatar May 28 '24 19:05 plredmond

Oh weird. ~~Maybe the CI-clippy is getting some stricter options than my local one.~~[Edit: No, I just forgot to run it] Ty

plredmond avatar May 28 '24 19:05 plredmond