absolufy-imports - No relative imports - PEP8#7204
Merged
Illviljan merged 12 commits intopydata:mainfrom Dec 7, 2022
Merged
Conversation
for more information, see https://pre-commit.ci
Collaborator
|
I have no particular preference on which, but +0.5 on having a standard. Also PyLance in VSCode has (temporarily, apparently) defaulted to making all imports absolute. So perhaps that will establish a standard. |
Contributor
|
Thanks for the contribution and the patience! @Illviljan |
dcherian
added a commit
to dcherian/xarray
that referenced
this pull request
Dec 8, 2022
* main: absolufy-imports - No relative imports - PEP8 (pydata#7204) [skip-ci] whats-new for dev (pydata#7351) Whats-new: 2022.12.0 (pydata#7345) Fix assign_coords resetting all dimension coords to default index (pydata#7347)
dcherian
reviewed
Dec 8, 2022
| import xarray as xr | ||
|
|
||
| from . import parameterized, randn, requires_dask | ||
| from asv_bench.benchmarks import parameterized, randn, requires_dask |
Contributor
There was a problem hiding this comment.
This makes our benchmarks fail unfortunately:
STDERR -------->
Error: Traceback (most recent call last):
File "/home/runner/micromamba-root/envs/xarray-tests/lib/python3.10/site-packages/asv/benchmark.py", line 1435, in <module>
main()
File "/home/runner/micromamba-root/envs/xarray-tests/lib/python3.10/site-packages/asv/benchmark.py", line 1428, in main
commands[mode](args)
File "/home/runner/micromamba-root/envs/xarray-tests/lib/python3.10/site-packages/asv/benchmark.py", line 1103, in main_discover
list_benchmarks(benchmark_dir, fp)
File "/home/runner/micromamba-root/envs/xarray-tests/lib/python3.10/site-packages/asv/benchmark.py", line 1088, in list_benchmarks
for benchmark in disc_benchmarks(root):
File "/home/runner/micromamba-root/envs/xarray-tests/lib/python3.10/site-packages/asv/benchmark.py", line 985, in disc_benchmarks
for module in disc_modules(root_name, ignore_import_errors=ignore_import_errors):
File "/home/runner/micromamba-root/envs/xarray-tests/lib/python3.10/site-packages/asv/benchmark.py", line 967, in disc_modules
for item in disc_modules(name, ignore_import_errors=ignore_import_errors):
File "/home/runner/micromamba-root/envs/xarray-tests/lib/python3.10/site-packages/asv/benchmark.py", line 950, in disc_modules
module = import_module(module_name)
File "/home/runner/work/xarray/xarray/asv_bench/.asv/env/3e1d7de4e47af51e3e41695ae1884ae2/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 843, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/runner/work/xarray/xarray/asv_bench/benchmarks/dataarray_missing.py", line 4, in <module>
from asv_bench.benchmarks import parameterized, randn, requires_dask
ModuleNotFoundError: No module named 'asv_bench'
There was a problem hiding this comment.
Hey, thanks for using absolufy-imports - just for reference, in pandas we don't use it on asv_bench
If you add a line to the hook with - files: ^xarray/, and revert the changes to asv_bench, then I think it should work fine
Illviljan
added a commit
to Illviljan/xarray
that referenced
this pull request
Dec 8, 2022
This reverts commit 6e77f5e.
dcherian
pushed a commit
that referenced
this pull request
Dec 9, 2022
* Revert "absolufy-imports - No relative imports - PEP8 (#7204)" This reverts commit 6e77f5e. * absolufy-imports - No relative imports - PEP8 * absolufy-imports - No relative imports - PEP8 * absolufy-imports - No relative imports - PEP8 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update whats-new.rst * Revert "[pre-commit.ci] auto fixes from pre-commit.com hooks" This reverts commit 9f50f5d. * Update .pre-commit-config.yaml * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I saw dask has started using absolute imports in dask/dask#8796.
I find it much more readable and there's a nice pre-commit for it as well.
Easiest way to deal with the merge conflicts is probably to just accept your changes and let pre-commit fix them afterwards.