forked from M-Labs/nac3
Compare commits
2 Commits
5a5656e983
...
c94f407732
Author | SHA1 | Date | |
---|---|---|---|
c94f407732 | |||
d9ac662787 |
@ -863,14 +863,12 @@ impl Nac3 {
|
||||
}
|
||||
}
|
||||
|
||||
/// Retrieves the Name.id from a decorator, supports decorators with arguments.
|
||||
fn decorator_id_string(decorator: &Located<ExprKind>) -> Option<String> {
|
||||
if let ExprKind::Name { id, .. } = decorator.node {
|
||||
// Bare decorator
|
||||
return Some(id.to_string());
|
||||
} else if let ExprKind::Call { func, .. } = &decorator.node {
|
||||
// Decorators that are calls (e.g. "@rpc()") have Call for the node,
|
||||
// need to extract the id from within.
|
||||
// decorators with flags (e.g. rpc async) have Call for the node,
|
||||
// extract the id from within
|
||||
if let ExprKind::Name { id, .. } = func.node {
|
||||
return Some(id.to_string());
|
||||
}
|
||||
@ -878,11 +876,10 @@ fn decorator_id_string(decorator: &Located<ExprKind>) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Retrieves flags from a decorator, if any.
|
||||
fn decorator_get_flags(decorator: &Located<ExprKind>) -> Vec<Constant> {
|
||||
let mut flags = vec![];
|
||||
if let ExprKind::Call { keywords, .. } = &decorator.node {
|
||||
for keyword in keywords {
|
||||
for keyword in keywords.iter() {
|
||||
if keyword.node.arg != Some("flags".into()) {
|
||||
continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user