mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-30 23:27:27 +00:00
Remove an unsafe access in the resolver (#5428)
This commit is contained in:
parent
69c4b7fa11
commit
c5e20505f8
1 changed files with 9 additions and 5 deletions
|
@ -173,8 +173,11 @@ fn resolve_module_descriptor(
|
||||||
resolved_paths.len() == module_descriptor.name_parts.len()
|
resolved_paths.len() == module_descriptor.name_parts.len()
|
||||||
};
|
};
|
||||||
|
|
||||||
let is_partly_resolved =
|
let is_partly_resolved = if resolved_paths.is_empty() {
|
||||||
!resolved_paths.is_empty() && resolved_paths.len() < module_descriptor.name_parts.len();
|
false
|
||||||
|
} else {
|
||||||
|
resolved_paths.len() < module_descriptor.name_parts.len()
|
||||||
|
};
|
||||||
|
|
||||||
ImportResult {
|
ImportResult {
|
||||||
is_relative: false,
|
is_relative: false,
|
||||||
|
@ -286,9 +289,10 @@ fn resolve_best_absolute_import<Host: host::Host>(
|
||||||
// If we resolved to a namespace package, ensure that all imported symbols are
|
// If we resolved to a namespace package, ensure that all imported symbols are
|
||||||
// present in the namespace package's "implicit" imports.
|
// present in the namespace package's "implicit" imports.
|
||||||
if typings_import.is_namespace_package
|
if typings_import.is_namespace_package
|
||||||
&& typings_import.resolved_paths[typings_import.resolved_paths.len() - 1]
|
&& typings_import
|
||||||
.as_os_str()
|
.resolved_paths
|
||||||
.is_empty()
|
.last()
|
||||||
|
.map_or(false, |path| path.as_os_str().is_empty())
|
||||||
{
|
{
|
||||||
if typings_import
|
if typings_import
|
||||||
.implicit_imports
|
.implicit_imports
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue