-
Notifications
You must be signed in to change notification settings - Fork 131
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
Renamed files, pre-commit flake8 #401
base: master
Are you sure you want to change the base?
Conversation
Thanks for this. Do you have a clean test case that will reproduce circular import error and know if there is also a problem with the current public (pypi) release? The only times I've seen it in the past are in meta-loading contexts like using pycharm debugger, where it's not clear where the problem lies. The potential problem with renaming the modules is that there are now multiple external likelihoods inheriting and using Cobaya, so if you make a breaking name change like this they are likely to break (and there's no very obvious way to make a compatibility layer that wouldn't also potentially trigger circular dependency). |
Thanks for the patch! A couple of comments: I agree naming modules as built-in ones (or commonly used packages, as for In any case, let's just think of names that are less redundant than On the other hands, wrappers could (I think) be dealt with at the For |
Hi @JesusTorrado, As far as I can tell this error only occurs when using any gh version, while the PyPI version works fine. Still, better to fix the error now than later down the line. I'm easy on names, I'll change them to your suggestion unless @cmbant has other suggestions. Wrapper modules are easier to read and I'm not sure putting them in I can add |
The python rules do seem to be quite clear that "import typing" always means the "typing" available from the global path, not the local package. I would have thought "pip install -e" shouldn't add the inside of the cobaya/ directory to path, in which case cobaya.typing should not be on the path and hence still OK, so a bit odd (and certainly not something I see generally, though have occasionally seen similar when e.g. debugging in PyCharm where things are being called indirectly via pytest/internal debugging wrappers that somehow get module imports messed up). importing yaml_load from cobaya.yaml seems to be quite common in 3rd party repos, so should keep that working. Does cobaya.yaml actually cause a problem? |
Are you sure it's not saying that "
|
The current code never does "import typing" not referring to the standard module, so doesn't seem inconsistent. Renaming certainly avoids the issue, though "running" cobaya/typing.py etc I think is not something we need to work, and it does still seem to me that what we have should work (I think the Pycharm issue disappeared after some update, suggesting a temporary module bug in one of the packaging/testing libraries). numpy of course also has a numpy.typing submodule, which is probably why we used that name. |
That is not the issue. The issue is that there is a module named Modules should not give uncaught errors when run, and certainly not when imported. The current project in theory should not work because of the above error. The numpy typing module is structured differently, being a directory rather than a file, and does not import from the standard |
@JesusTorrado I've renamed the files to your suggested names and added pyproject-flake8. |
At the end of the day, I think I agree with @cmbant. If at all, the only would-be-problem is If a linter/debugger/LSP-server complains, it's a bug of its name resolver. I would personally close this and open a separate one for the flake8 thing. |
Are you intending to create another PR for the pre-commit hook with pyproject.toml? There is no particular hurry, but if you have decided not to, please let me know to try to experiment with it myself. But it would be better if you appear as the one doing the commits :) |
Hi @JesusTorrado |
Renamed:
cobaya/typing.py
->cobaya/cobaya_typing.py
,cobaya/yaml.py
->cobaya/cobaya_yaml.py
to prevent circular imports.cobaya/input.py
->cobaya/cobaya_input.py
to prevent clashes withinput()
.Added
.flake8
with options from the docs.Added pre-commit file to run flake8 on commit.