mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 06:41:23 +00:00
[ty] Split out another constructor for ModuleName
This makes it a little more flexible to call. For example, we might have a `StmtImport` and not a `StmtImportFrom`.
This commit is contained in:
parent
306ef3bb02
commit
5b00ec981b
1 changed files with 9 additions and 3 deletions
|
@ -285,10 +285,16 @@ impl ModuleName {
|
||||||
range: _,
|
range: _,
|
||||||
node_index: _,
|
node_index: _,
|
||||||
} = node;
|
} = node;
|
||||||
|
Self::from_identifier_parts(db, importing_file, module.as_deref(), *level)
|
||||||
|
}
|
||||||
|
|
||||||
let module = module.as_deref();
|
pub(crate) fn from_identifier_parts(
|
||||||
|
db: &dyn Db,
|
||||||
if let Some(level) = NonZeroU32::new(*level) {
|
importing_file: File,
|
||||||
|
module: Option<&str>,
|
||||||
|
level: u32,
|
||||||
|
) -> Result<Self, ModuleNameResolutionError> {
|
||||||
|
if let Some(level) = NonZeroU32::new(level) {
|
||||||
relative_module_name(db, importing_file, module, level)
|
relative_module_name(db, importing_file, module, level)
|
||||||
} else {
|
} else {
|
||||||
module
|
module
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue