Skip to content
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] Cleanup some KnownClass APIs #14269

Merged
merged 1 commit into from
Nov 11, 2024
Merged

Conversation

AlexWaygood
Copy link
Member

Summary

  • Rename KnownClass::to_class to KnownClass::to_class_literal. This is an oversight that should have been done as part of [red-knot] Introduce a new ClassLiteralType struct #14108.
  • Rename KnownClass::maybe_from_moduletoKnownClass::try_from_module`. I think this fits better with typical Rust naming conventions.
  • Inline KnownClass::from_name. I don't think it would ever produce desirable results if you called this method from outside of KnownClass::try_from_module (because you also need to check which module the class is coming from, for correctness), so inlining it seems best here.
  • Make use of the CoreStdlibModule enum in red_knot_python_semantic/src/stdlib.rs to reduce code duplication and reduce hardcoded strings.

Test Plan

cargo test -p red_knot_python_semantic

@AlexWaygood AlexWaygood added the red-knot Multi-file analysis & type inference label Nov 11, 2024
@AlexWaygood AlexWaygood enabled auto-merge (squash) November 11, 2024 11:51
@AlexWaygood AlexWaygood merged commit 9180635 into main Nov 11, 2024
19 checks passed
@AlexWaygood AlexWaygood deleted the alex/knownclass-api branch November 11, 2024 11:54
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
red-knot Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant