public/private context managers for module attributes

One of the issues with defining module attributes via

public(SEVEN=7)
public(a_bar=Bar())

is that it causes linters, such as flake8, to throw errors when those definitions are used later in the module. For example:

Screenshot_2021-08-19_at_07.59.29

One way to achieve the above without causing linter to fail would be to implement public and private as context managers. For example, the above could be implemented as a context manager as follows:

with public:
    SEVEN=7
    a_bar=Bar()

which we can now see also doesn't throw an linting error in the other example:

Screenshot_2021-08-19_at_08.04.17

Anyway, just a suggestion that might make the package useful more broadly 🙂

Edited by Sam Morley-Short