Allow named expressions in __all__ assignments (#7673)

## Summary

This PR adds support for named expressions when analyzing `__all__`
assignments, as per https://github.com/astral-sh/ruff/issues/7672. It
also loosens the enforcement around assignments like: `__all__ =
list(some_other_expression)`. We shouldn't flag these as invalid, even
though we can't analyze the members, since we _know_ they evaluate to a
`list`.

Closes https://github.com/astral-sh/ruff/issues/7672.

## Test Plan

`cargo test`
This commit is contained in:
Charlie Marsh 2023-09-27 00:36:55 -04:00 committed by GitHub
parent fbbc982c29
commit 0a8cad2550
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 5 deletions

View file

@ -20,6 +20,8 @@ __all__ = foo.bar # [invalid-all-format]
__all__ = foo["bar"] # [invalid-all-format]
__all__ = (foo := bar) # [invalid-all-format]
__all__ = ["Hello"]
__all__ = ("Hello",)
@ -41,3 +43,7 @@ __all__ = __all__ + ["Hello"]
__all__ = __all__ + multiprocessing.__all__
__all__ = list[str](["Hello", "world"])
__all__ = list[str](foo())
__all__ = (foo := ["Hello", "world"])