red-knot: move symbol lookups in symbol.rs#16152
Conversation
0220b09 to
59aef97
Compare
884da77 to
96b5a35
Compare
59aef97 to
369ec81
Compare
AlexWaygood
left a comment
There was a problem hiding this comment.
Nice! It's great to move these out of types.rs.
Bikeshedding: I'm wondering if we should put these in a new submodule (lookup.rs?) rather than symbol.rs. The APIs in symbol.rs are currently quite abstract and don't have much to do with the business of implementing Python's lookup semantics correctly; these APIs we're moving here feel a little different from that. I don't have a strong opinion, however; I'm happy to go with this
We could also add some more doc-comments to the module_type_symbol function, as I mentioned in #16133 (comment)
carljm
left a comment
There was a problem hiding this comment.
Looks good to me! I agree with all of Alex's comments.
369ec81 to
89cefbe
Compare
We added a But, I also see this comment on ruff/crates/red_knot_python_semantic/src/symbol.rs Lines 176 to 177 in 89cefbe which makes me hesitant to do it now and can be done easily in the future as well. |
* main: (60 commits) [`refurb`] Manual timezone monkeypatching (`FURB162`) (#16113) [`pyupgrade`] Do not upgrade functional TypedDicts with private field names to the class-based syntax (`UP013`) (#16219) Improve docs for PYI019 (#16229) Refactor `CallOutcome` to `Result` (#16161) Fix minor punctuation errors (#16228) Include document specific debug info (#16215) Update server to return the debug info as string (#16214) [`airflow`] Group `ImportPathMoved` and `ProviderName` to avoid misusing (`AIR303`) (#16157) Fix unstable formatting of trailing end-of-line comments of parenthesized attribute values (#16187) Ignore source code actions for a notebook cell (#16154) Add FAQ entry for `source.*` code actions in Notebook (#16212) red-knot: move symbol lookups in `symbol.rs` (#16152) better error messages while loading configuration `extend`s (#15658) Format `index.css` (#16207) Improve API exposed on `ExprStringLiteral` nodes (#16192) Update Rust crate tempfile to v3.17.0 (#16202) Update cloudflare/wrangler-action action to v3.14.0 (#16203) Update NPM Development dependencies (#16199) Update Rust crate smallvec to v1.14.0 (#16201) Update Rust crate codspeed-criterion-compat to v2.8.0 (#16200) ...
Summary
This PR does the following:
types.rsinsymbol.rs:symbolglobal_symbolimported_symbolsymbol_from_bindingssymbol_from_declarationsSymbolAndQualifiersSymbolFromDeclarationsResultstdlib.rsinsymbol.rsand removesstdlib.rs:known_module_symbolbuiltins_symboltyping_symbol(only for tests)typing_extensions_symbolbuiltins_module_scopecore_module_scopesymbol_from_bindings_implandsymbol_from_declarations_implto keepRequiresExplicitReExportan implementation detaildeclaration_typeapub(crate)as it's required insymbol_from_declarations(binding_typeis alreadypub(crate)The main motivation is to keep the implementation details private and only expose an ergonomic API which uses sane defaults for various scenario to avoid any mistakes from the caller. Refer to #16133 (comment), #16133 (comment) for details.