Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean up the exported names #324

Closed
grahamgower opened this issue Jun 9, 2021 · 2 comments · Fixed by #337
Closed

clean up the exported names #324

grahamgower opened this issue Jun 9, 2021 · 2 comments · Fixed by #337
Milestone

Comments

@grahamgower
Copy link
Member

We should use __all__ to only export names that are part of the public API. Also see mypy --strict output in #323, where the Module has no attribute "foo" suggests where we might consider explicit exports.

@grahamgower grahamgower added this to the 0.1.3 milestone Jun 9, 2021
@molpopgen
Copy link
Collaborator

Serious question: is it actually possible to satisfy mypy? In my experience, every warning or two that I silence seems to open up other cans of worms.

@grahamgower
Copy link
Member Author

Serious question: is it actually possible to satisfy mypy? In my experience, every warning or two that I silence seems to open up other cans of worms.

Scanning the mypy --strict output, I think there's a bunch of stuff that could be fixed quite easily. We can just ignore the hard bits. But given that we want demes to be used widely, I think it's worth making some effort to have good type annotations so that downstream projects can benefit from type checking too.

Apart from attrs classes, we're mostly using stock Python types (float, int, str) and simple containers (list, dict, tuple), so annotations for function params and return values shouldn't be too onerous. Of course, typing support is not as good in Python 3.6 as in Python 3.9, so there will be some constraints (e.g. having to say typing.List[float] instead of just list[float]).

grahamgower added a commit to grahamgower/demes-python that referenced this issue Jun 24, 2021
Closes popsim-consortium#324.

Note that non-public symbols are still accessible, and that some
applications, such as iPython, will ignore __all__ when offering
tab-completion suggestions.
grahamgower added a commit to grahamgower/demes-python that referenced this issue Jun 24, 2021
Closes popsim-consortium#324.

Note that non-public symbols are still accessible when referred to
explicitly by name. But here we use the module-level __dir__()
function to define which symbols are seen when using dir(<module-name>).
This is a Python >= 3.7 only feature, but the function is just ignored
on Python 3.6.
grahamgower added a commit to grahamgower/demes-python that referenced this issue Jun 24, 2021
Closes popsim-consortium#324.

Note that non-public symbols are still accessible when referred to
explicitly by name. But here we use the module-level __dir__()
function to define which symbols are seen when using dir(<module-name>).
This is a Python >= 3.7 only feature, but the function is just ignored
on Python 3.6.
grahamgower added a commit to grahamgower/demes-python that referenced this issue Jun 24, 2021
Closes popsim-consortium#324.

Note that non-public symbols are still accessible when referred to
explicitly by name. But here we use the module-level __dir__()
function to define which symbols are seen when using dir(<module-name>).
This is a Python >= 3.7 only feature, but the function is just ignored
on Python 3.6.
grahamgower added a commit to grahamgower/demes-python that referenced this issue Jun 24, 2021
Closes popsim-consortium#324.

Note that non-public symbols are still accessible when referred to
explicitly by name. But here we use the module-level __dir__()
function to define which symbols are seen when using dir(<module-name>).
This is a Python >= 3.7 only feature, but the function is just ignored
on Python 3.6.
grahamgower added a commit to grahamgower/demes-python that referenced this issue Jun 24, 2021
Closes popsim-consortium#324.

Note that non-public symbols are still accessible when referred to
explicitly by name. But here we use the module-level __dir__()
function to define which symbols are seen when using dir(<module-name>).
This is a Python >= 3.7 only feature, but the function is just ignored
on Python 3.6.
grahamgower added a commit to grahamgower/demes-python that referenced this issue Jul 5, 2021
Closes popsim-consortium#324.

Note that non-public symbols are still accessible when referred to
explicitly by name. But here we use the module-level __dir__()
function to define which symbols are seen when using dir(<module-name>).
This is a Python >= 3.7 only feature, but the function is just ignored
on Python 3.6.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants