Skip to content
This repository has been archived by the owner on Apr 14, 2022. It is now read-only.

__all__ evaluation #863

Merged
merged 9 commits into from
Apr 2, 2019
Merged

Conversation

jakebailey
Copy link
Member

@jakebailey jakebailey commented Apr 1, 2019

Fixes #620.
Fixes #619.

This adds support for concatenating lists using +, doing += on __all__, and calling append and extend on __all__. If something goes wrong (an unsupported operation on __all__ or some unsupported value), then the old behavior continues to be used. I don't track uses of __all__ indirectly (i.e. passing __all__ to something that modifies it), only direct actions. If __all__ is in a more complicated lvar (like __all__, foo = ...), then it is ignored. This can be improved later on when we fix up our multiple assignment issues.

This works well for Django models (see #620), but numpy's import cycles prevent this from having an effect, so the old behavior will be used.

Tests are WIP. I'll need to rebase/merge master when the refs per gets merged.

@jakebailey jakebailey changed the title [WIP] __all__ evaluation __all__ evaluation Apr 2, 2019
@jakebailey jakebailey merged commit 7bcb4b6 into microsoft:master Apr 2, 2019
@jakebailey jakebailey deleted the all-evaluation branch April 2, 2019 22:04
jakebailey added a commit to jakebailey/python-language-server that referenced this pull request Nov 1, 2019
Fixes microsoft#620.
Fixes microsoft#619.

This adds support for concatenating lists using `+`, doing `+=` on `__all__`, and calling `append` and `extend` on `__all__`. If something goes wrong (an unsupported operation on `__all__` or some unsupported value), then the old behavior continues to be used. I don't track uses of `__all__` indirectly (i.e. passing `__all__` to something that modifies it), only direct actions. If `__all__` is in a more complicated lvar (like `__all__, foo = ...`), then it is ignored. This can be improved later on when we fix up our multiple assignment issues.

This works well for Django models (see microsoft#620), but `numpy`'s import cycles prevent this from having an effect, so the old behavior will be used.

~Tests are WIP.~ I'll need to rebase/merge master when the refs per gets merged.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle complex __all__ assignments __all__ not being respected from an import *
2 participants