-
Notifications
You must be signed in to change notification settings - Fork 3
Removed wildcard imports #4
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
base: main
Are you sure you want to change the base?
Conversation
|
Thank you again for all of the hard work! First of all, I would like to break this up into a series of PRs so we can work on the individual modifications, this is more than just the wildcards at the moment, it also includes typing and modifications to the configuration and much more. So, just focusing on the wildcards for now, I personally believe that the public API should be almost all of the package, with the exception of what's in I would expect a regular user to Oh and |
|
I completely agree. I will split this up into a PR with only the internal imports changed. My implementation of from MDSplus import * # this will import `ctypes` and `numpy`
x = numpy.linspace(0.0, 1.0, 100)
conn = Connection("<your server>")but as you say if most people are using I'll get the updated PR mid week (probably). |
|
Thanks again! And aren't there rules about underscores and wildcards? What if we alias the imports of |
|
Would be easier to delete the objects which you don't want exposed.
from .connection import *
from .descriptors import *
from .exceptions import *
from .functions import *
# Delete system standard library and third party packages, which should not be exposed to users
del ctypes
del getpass
del logging
del numpy
del os
del socket
del sys
del time |
|
Oh that's an interesting idea, I think I could live with that. It mirrors what I do for the fake |
I have removed all internal wildcard imports.
While doing this I noticed what looks to be a bug.
DTYPE_RANGEis defined twice: once as a variable, and once as a function:mdsthin/mdsthin/internals/dtypedef.py
Line 148 in e361fd0
mdsthin/mdsthin/functions.py
Line 904 in e361fd0
My implementation of
mdsthin/__init__.pyis absolutely horrible! Nearly every variable, function, and class is exposed to the public. I have not made any change in what is exposed to the public, so the behaviour is identical. In my opinion nearly all of this should be removed. However, I didn't want to decide what to expose and what not to. Perhaps it would be best to leavemdsthin/__init__.pyunaltered with the wildcard imports left, until a decision is made on what should be exposed to the public?The imports are all formatted using
ruff check --select I --fix <file_name>this alphabetically sorts and groups the imports by: standard library, blank line, third party, blank line, internal imports.I also added a few extra tests. All tests passed on Python 3.7 - 3.13. However, I didn't run any of the ssh tests as we don't use ssh, and
test_root_whoaminever worked for me due to custom server settings.Hope some of this is of help.