Skip to content

Commit

Permalink
Ignore underscore references in type annotations (#9036)
Browse files Browse the repository at this point in the history
## Summary

Occasionally, valid code needs to use `argparse._SubParsersAction` in a
type annotation. This isn't great, but it's indicative of the fact that
public interfaces can return private types. If you accessed that private
type via a private interface, then we should be flagging the call site,
rather than the annotation.

Closes #9013.
  • Loading branch information
charliermarsh authored Dec 7, 2023
1 parent 9361e22 commit bbb0a0c
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ pub(crate) fn private_member_access(checker: &mut Checker, expr: &Expr) {
return;
};

if checker.semantic().in_annotation() {
return;
}

if (attr.starts_with("__") && !attr.ends_with("__"))
|| (attr.starts_with('_') && !attr.starts_with("__"))
{
Expand Down

0 comments on commit bbb0a0c

Please sign in to comment.