mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-31 23:57:35 +00:00
Remove Int
wrapper type from parser (#7577)
## Summary This is only used for the `level` field in relative imports (e.g., `from ..foo import bar`). It seems unnecessary to use a wrapper here, so this PR changes to a `u32` directly.
This commit is contained in:
parent
6c3378edb1
commit
4d6f5ff0a7
16 changed files with 75 additions and 101 deletions
|
@ -253,18 +253,18 @@ ImportStatement: ast::Stmt = {
|
|||
},
|
||||
};
|
||||
|
||||
ImportFromLocation: (Option<ast::Int>, Option<ast::Identifier>) = {
|
||||
ImportFromLocation: (Option<u32>, Option<ast::Identifier>) = {
|
||||
<dots: ImportDots*> <name:DottedName> => {
|
||||
(Some(ast::Int::new(dots.iter().map(ast::Int::to_u32).sum())), Some(name))
|
||||
(Some(dots.iter().sum()), Some(name))
|
||||
},
|
||||
<dots: ImportDots+> => {
|
||||
(Some(ast::Int::new(dots.iter().map(ast::Int::to_u32).sum())), None)
|
||||
(Some(dots.iter().sum()), None)
|
||||
},
|
||||
};
|
||||
|
||||
ImportDots: ast::Int = {
|
||||
"..." => ast::Int::new(3),
|
||||
"." => ast::Int::new(1),
|
||||
ImportDots: u32 = {
|
||||
"..." => 3,
|
||||
"." => 1,
|
||||
};
|
||||
|
||||
ImportAsNames: Vec<ast::Alias> = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue