Skip to content

Commit

Permalink
Apply Micha's suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood committed Mar 22, 2024
1 parent 6086cb7 commit 20e70c3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crates/ruff_linter/src/checkers/ast/analyze/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pub(crate) fn definitions(checker: &mut Checker) {
for ContextualizedDefinition {
definition,
visibility,
} in definitions.resolve(exports.as_deref()).iter()
} in definitions.resolve(&exports.unwrap_or_default()).iter()
{
let docstring = docstrings::extraction::extract_docstring(definition);

Expand Down
10 changes: 3 additions & 7 deletions crates/ruff_python_semantic/src/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl<'a> Definitions<'a> {
}

/// Resolve the visibility of each definition in the collection.
pub fn resolve(self, exports: Option<&[DunderAllName]>) -> ContextualizedDefinitions<'a> {
pub fn resolve(self, exports: &[DunderAllName]) -> ContextualizedDefinitions<'a> {
let mut definitions: IndexVec<DefinitionId, ContextualizedDefinition<'a>> =
IndexVec::with_capacity(self.len());

Expand All @@ -201,9 +201,7 @@ impl<'a> Definitions<'a> {
MemberKind::Class(class) => {
let parent = &definitions[member.parent];
if parent.visibility.is_private()
|| exports.is_some_and(|exports| {
!exports.iter().any(|export| export.name == member.name())
})
|| !exports.iter().any(|export| export.name == member.name())
{
Visibility::Private
} else {
Expand All @@ -223,9 +221,7 @@ impl<'a> Definitions<'a> {
MemberKind::Function(function) => {
let parent = &definitions[member.parent];
if parent.visibility.is_private()
|| exports.is_some_and(|exports| {
!exports.iter().any(|export| export.name == member.name())
})
|| !exports.iter().any(|export| export.name == member.name())
{
Visibility::Private
} else {
Expand Down

0 comments on commit 20e70c3

Please sign in to comment.