-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
red-knot: move symbol lookups in symbol.rs
#16152
Conversation
0220b09
to
59aef97
Compare
884da77
to
96b5a35
Compare
59aef97
to
369ec81
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.rs
insymbol.rs
:symbol
global_symbol
imported_symbol
symbol_from_bindings
symbol_from_declarations
SymbolAndQualifiers
SymbolFromDeclarationsResult
stdlib.rs
insymbol.rs
and removesstdlib.rs
:known_module_symbol
builtins_symbol
typing_symbol
(only for tests)typing_extensions_symbol
builtins_module_scope
core_module_scope
symbol_from_bindings_impl
andsymbol_from_declarations_impl
to keepRequiresExplicitReExport
an implementation detaildeclaration_type
apub(crate)
as it's required insymbol_from_declarations
(binding_type
is 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.