mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 06:11:21 +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: _,
|
||||
node_index: _,
|
||||
} = node;
|
||||
Self::from_identifier_parts(db, importing_file, module.as_deref(), *level)
|
||||
}
|
||||
|
||||
let module = module.as_deref();
|
||||
|
||||
if let Some(level) = NonZeroU32::new(*level) {
|
||||
pub(crate) fn from_identifier_parts(
|
||||
db: &dyn Db,
|
||||
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)
|
||||
} else {
|
||||
module
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue