ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 8.3 months ago (distributed domain, exempt) |
| History drop | FAIL | isNull(history_drop_reason) | tooold |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://github.com/dask/distributed/issues/5889 |
| Last Crawled | 2025-08-07 06:12:31 (8 months ago) |
| First Indexed | not set |
| HTTP Status Code | 200 |
| Meta Title | [Style] Absolute vs Relative imports · Issue #5889 · dask/distributed |
| Meta Description | We're using a lot of relative imports in this package and we're not very consistent about when and how to use which. Counting occurrences in the entire code base slightly favours absolute imports (about 56%). PEP8 recommends the usage of... |
| Meta Canonical | null |
| Boilerpipe Text | We're using a lot of relative imports in this package and we're not very consistent about when and how to use which. Counting occurrences in the entire code base slightly favours absolute imports (about 56%). PEP8 recommends the usage of absolute imports over relative imports unless a complex package layout would require unnecessarily verbose import statements Absolute imports are recommended, as they are usually more readable and tend to be better behaved (or at least give better error messages) if the import system is incorrectly configured (such as when a directory inside a package ends up on sys.path):
[...]
However, explicit relative imports are an acceptable alternative to absolute imports, especially when dealing with complex package layouts where using absolute imports would be unnecessarily verbose: I personally prefer absolute imports since they are much less ambiguous and portable. For instance, there are 24 from .core import and four from ..core import statements and we have six core.py files. It's not hard to figure out where the imports are pointing to but an absolute version removes ambiguity, especially for multi-level relative references If we go for absolute imports, a follow up question would be whether we want to automate this, e.g. https://github.com/MarcoGorelli/absolufy-imports Thoughts? |
| Markdown | [Skip to content](https://github.com/dask/distributed/issues/5889#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fdask%2Fdistributed%2Fissues%2F5889)
Appearance settings
- Product
- [GitHub Copilot Write better code with AI](https://github.com/features/copilot)
- [GitHub Spark New Build and deploy intelligent apps](https://github.com/features/spark)
- [GitHub Models New Manage and compare prompts](https://github.com/features/models)
- [GitHub Advanced Security Find and fix vulnerabilities](https://github.com/security/advanced-security)
- [Actions Automate any workflow](https://github.com/features/actions)
- [Codespaces Instant dev environments](https://github.com/features/codespaces)
- [Issues Plan and track work](https://github.com/features/issues)
- [Code Review Manage code changes](https://github.com/features/code-review)
- [Discussions Collaborate outside of code](https://github.com/features/discussions)
- [Code Search Find more, search less](https://github.com/features/code-search)
Explore
- [Why GitHub](https://github.com/why-github)
- [All features](https://github.com/features)
- [Documentation](https://docs.github.com/)
- [GitHub Skills](https://skills.github.com/)
- [Blog](https://github.blog/)
- Solutions
By company size
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
By use case
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
By industry
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
- Resources
Topics
- [AI](https://github.com/resources/articles/ai)
- [DevOps](https://github.com/resources/articles/devops)
- [Security](https://github.com/resources/articles/security)
- [Software Development](https://github.com/resources/articles/software-development)
- [View all](https://github.com/resources/articles)
Explore
- [Learning Pathways](https://resources.github.com/learn/pathways)
- [Events & Webinars](https://resources.github.com/)
- [Ebooks & Whitepapers](https://github.com/resources/whitepapers)
- [Customer Stories](https://github.com/customer-stories)
- [Partners](https://partner.github.com/)
- [Executive Insights](https://github.com/solutions/executive-insights)
- Open Source
- [GitHub Sponsors Fund open source developers](https://github.com/sponsors)
- [The ReadME Project GitHub community articles](https://github.com/readme)
Repositories
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
- Enterprise
- [Enterprise platform AI-powered developer platform](https://github.com/enterprise)
Available add-ons
- [GitHub Advanced Security Enterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for business Enterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium Support Enterprise-grade 24/7 support](https://github.com/premium-support)
- [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Cancel
Create saved search
[Sign in](https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fdask%2Fdistributed%2Fissues%2F5889)
[Sign up](https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=dask%2Fdistributed)
Appearance settings
Resetting focus
You signed in with another tab or window. [Reload](https://github.com/dask/distributed/issues/5889) to refresh your session. You signed out in another tab or window. [Reload](https://github.com/dask/distributed/issues/5889) to refresh your session. You switched accounts on another tab or window. [Reload](https://github.com/dask/distributed/issues/5889) to refresh your session.
Dismiss alert
{{ message }}
[dask](https://github.com/dask) / **[distributed](https://github.com/dask/distributed)** Public
- Sponsor
# Sponsor dask/distributed
##### GitHub Sponsors
[Learn more about Sponsors](https://github.com/sponsors)
[](https://github.com/numfocus)
[numfocus](https://github.com/numfocus)
[numfocus](https://github.com/numfocus)
[Sponsor](https://github.com/sponsors/numfocus)
##### External links
<https://numfocus.org/donate-to-dask>

[tidelift.com/funding/github/**pypi/dask**](https://tidelift.com/funding/github/pypi/dask)
[Learn more about funding links in repositories](https://docs.github.com/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/displaying-a-sponsor-button-in-your-repository).
[Report abuse](https://github.com/contact/report-abuse?report=dask%2Fdistributed+%28Repository+Funding+Links%29)
- [Notifications](https://github.com/login?return_to=%2Fdask%2Fdistributed)
You must be signed in to change notification settings
- [Fork 735](https://github.com/login?return_to=%2Fdask%2Fdistributed)
- [Star 1.6k](https://github.com/login?return_to=%2Fdask%2Fdistributed)
- [Code](https://github.com/dask/distributed)
- [Issues 1.2k](https://github.com/dask/distributed/issues)
- [Pull requests 259](https://github.com/dask/distributed/pulls)
- [Discussions](https://github.com/dask/distributed/discussions)
- [Actions](https://github.com/dask/distributed/actions)
- [Projects 0](https://github.com/dask/distributed/projects)
- [Wiki](https://github.com/dask/distributed/wiki)
- [Security 1](https://github.com/dask/distributed/security)
[Uh oh\!](https://github.com/dask/distributed/security)
[There was an error while loading.](https://github.com/dask/distributed/security) [Please reload this page](https://github.com/dask/distributed/issues/5889).
- [Insights](https://github.com/dask/distributed/pulse)
Additional navigation options
- [Code](https://github.com/dask/distributed)
- [Issues](https://github.com/dask/distributed/issues)
- [Pull requests](https://github.com/dask/distributed/pulls)
- [Discussions](https://github.com/dask/distributed/discussions)
- [Actions](https://github.com/dask/distributed/actions)
- [Projects](https://github.com/dask/distributed/projects)
- [Wiki](https://github.com/dask/distributed/wiki)
- [Security](https://github.com/dask/distributed/security)
- [Insights](https://github.com/dask/distributed/pulse)
# \[Style\] Absolute vs Relative imports \#5889
[New issue](https://github.com/login?return_to=https://github.com/dask/distributed/issues/5889)
Copy link
[New issue](https://github.com/login?return_to=https://github.com/dask/distributed/issues/5889)
Copy link
Closed
[\#5924](https://github.com/dask/distributed/pull/5924)
Closed
[\[Style\] Absolute vs Relative imports](https://github.com/dask/distributed/issues/5889#top)
\#5889
[\#5924](https://github.com/dask/distributed/pull/5924)
Copy link
[](https://github.com/fjetter)
## Description
[](https://github.com/fjetter)
[fjetter](https://github.com/fjetter)
opened
[on Mar 2, 2022](https://github.com/dask/distributed/issues/5889#issue-1157026371)
Member
Issue body actions
We're using a lot of relative imports in this package and we're not very consistent about when and how to use which. Counting occurrences in the entire code base slightly favours absolute imports (about 56%).
[PEP8](https://www.python.org/dev/peps/pep-0008/) recommends the usage of absolute imports over relative imports unless a complex package layout would require unnecessarily verbose import statements
> Absolute imports are recommended, as they are usually more readable and tend to be better behaved (or at least give better error messages) if the import system is incorrectly configured (such as when a directory inside a package ends up on sys.path):
> \[...\]
> However, explicit relative imports are an acceptable alternative to absolute imports, especially when dealing with complex package layouts where using absolute imports would be unnecessarily verbose:
I personally prefer absolute imports since they are much less ambiguous and portable.
For instance, there are 24 `from .core import` and four `from ..core import` statements and we have six `core.py` files. It's not hard to figure out where the imports are pointing to but an absolute version removes ambiguity, especially for multi-level relative references
If we go for absolute imports, a follow up question would be whether we want to automate this, e.g. <https://github.com/MarcoGorelli/absolufy-imports>
Thoughts?
## Activity
[fjetter](https://github.com/fjetter)
mentioned this
[on Mar 2, 2022](https://github.com/dask/distributed/issues/5889#event-1171248651)
- [Unblock event loop while waiting for ThreadpoolExecutor to shut down \#5883](https://github.com/dask/distributed/pull/5883)
[](https://github.com/crusaderky)
### crusaderky commented on Mar 2, 2022
[](https://github.com/crusaderky)
[crusaderky](https://github.com/crusaderky)
[on Mar 2, 2022](https://github.com/dask/distributed/issues/5889#issuecomment-1056840395)
Collaborator
As far as I'm aware the current pattern in dask and distributed is absolute imports in the tests and relative imports everywhere else. This is also what I've always used in all my personal projects.
This was *the* pattern in Python 2 where absolute imports were a hot mess as the interpreter would first try importing them relative to the current path and only then from site-packages. Thankfully this is no longer the case in Python 3.
I was not aware about the wording in the PEP8 - it must have been changed after transitioning from 2 to 3.
I'm happy to change to comply with PEP8.
> would be whether we want to automate this
This strikes me as something isort should do. Maybe there's a switch for it?
[](https://github.com/fjetter)
### fjetter commented on Mar 2, 2022
[](https://github.com/fjetter)
[fjetter](https://github.com/fjetter)
[on Mar 2, 2022](https://github.com/dask/distributed/issues/5889#issuecomment-1056875370)
MemberAuthor
> This strikes me as something isort should do. Maybe there's a switch for it?
[PyCQA/isort\#1677](https://github.com/PyCQA/isort/issues/1677)
[](https://github.com/ian-r-rose)
### ian-r-rose commented on Mar 3, 2022
[](https://github.com/ian-r-rose)
[ian-r-rose](https://github.com/ian-r-rose)
[on Mar 3, 2022](https://github.com/dask/distributed/issues/5889#issuecomment-1058241117)
· edited by [ian-r-rose](https://github.com/ian-r-rose)
Edits
Collaborator
I was unaware of the recommendation for absolute imports in PEP8, but I don't really agree with it, and second [@crusaderky](https://github.com/crusaderky)'s sentiment that things were a mess before relative imports were an option.
I'd like to specifically call out that people's software environments can be a mess, and can be broken in ways that are too numerous to count (especially for inexperienced users). I've seen cases where absolute imports find the wrong version of the package that is installed somewhere weird and things start to fail in impossible-to-debug ways. We're obviously not responsible for broken user environments, but to me there is some value in things possibly failing faster. This is directly opposed to the PEP8 assertion that such absolute import failures are "better behaved", and "give better error messages", so 🤷♂️
👍React with 👍1
turicas
[](https://github.com/jsignell)
### jsignell commented on Mar 3, 2022
[](https://github.com/jsignell)
[jsignell](https://github.com/jsignell)
[on Mar 3, 2022](https://github.com/dask/distributed/issues/5889#issuecomment-1058264415)
Member
If we decide to enforce absolute imports we can definitely automate that. I have used absolutify on other projects.
I have no opinion on whether absolute/relative is preferable.
[](https://github.com/fjetter)
### fjetter commented on Mar 3, 2022
[](https://github.com/fjetter)
[fjetter](https://github.com/fjetter)
[on Mar 3, 2022](https://github.com/dask/distributed/issues/5889#issuecomment-1058322512)
MemberAuthor
> I'd like to specifically call out that people's software environments can be a mess, and can be broken in ways that are too numerous to count (especially for inexperienced users). I've seen cases where absolute imports find the wrong version of the package that is installed somewhere weird and things start to fail in impossible-to-debug ways. We're obviously not responsible for broken user environments, but to me there is some value in things possibly failing faster. This is directly opposed to the PEP8 assertion that such absolute import failures are "better behaved", and "give better error messages", so
I'm not too concerned about this. If that was a problem, I am pretty sure we'd have heard of this before since we're not 100% consistent with how we import.
IMHO, there is not a technical reason for a properly packaged library to prefer the one over the other.
I am mostly advocating for a consistent code style. I consider absolute imports much easier to read and don't think our tree is complex enough that we require shortening.
I hate debating about style on a PR and **love** that black, isort, etc. takes care of most of the ambiguity. If we can somehow enforce the rule "relative in modules, absolute in test" using a pre-commit hook, I'm in. I care about automation and linting way more than about the actual style :)
[](https://github.com/gjoseph92)
### gjoseph92 commented on Mar 3, 2022
[](https://github.com/gjoseph92)
[gjoseph92](https://github.com/gjoseph92)
[on Mar 3, 2022](https://github.com/dask/distributed/issues/5889#issuecomment-1058388961)
Collaborator
> I hate debating about style on a PR and **love** that black, isort, etc. takes care of most of the ambiguity. If we can somehow enforce the rule "relative in modules, absolute in test" using a pre-commit hook, I'm in. I care about automation and linting way more than about the actual style :)
\+1, would love to see this.
I also would prefer absolute imports in code. It makes any refactoring much easier, for one thing, and is unambiguous to read.
[](https://github.com/MarcoGorelli)
### MarcoGorelli commented on Mar 9, 2022
[](https://github.com/MarcoGorelli)
[MarcoGorelli](https://github.com/MarcoGorelli)
[on Mar 9, 2022](https://github.com/dask/distributed/issues/5889#issuecomment-1062913498)
· edited by [MarcoGorelli](https://github.com/MarcoGorelli)
Edits
Hey, thanks for looking into absolufy-imports
> If we can somehow enforce the rule "relative in modules, absolute in test" using a pre-commit hook
something like
```
- repo: https://github.com/MarcoGorelli/absolufy-imports
rev: v0.3.1
hooks:
- id: absolufy-imports
name: absolufy-imports (modules)
files: ^distributed/
exclude: /tests/
args: [--never]
- id: absolufy-imports
name: absolufy-imports (tests)
files: /tests/
```
might work for you?
> This strikes me as something isort should do. Maybe there's a switch for it?
Yeah, I haven't had much free time recently, but I'd like to try to get this into isort eventually (not soon, unfortunately)
[MarcoGorelli](https://github.com/MarcoGorelli)
mentioned this
[on Mar 9, 2022](https://github.com/dask/distributed/issues/5889#event-1172651095)
- [absolufy-imports \#5917](https://github.com/dask/distributed/pull/5917)
[](https://github.com/fjetter)
### fjetter commented on Mar 9, 2022
[](https://github.com/fjetter)
[fjetter](https://github.com/fjetter)
[on Mar 9, 2022](https://github.com/dask/distributed/issues/5889#issuecomment-1063181551)
MemberAuthor
I suggest anybody who is following this issue to have a look at [\#5917](https://github.com/dask/distributed/pull/5917) It is not a huge diff but shows a few interesting examples. If that helps with a decision, I'm sure we can open another PR showing the opposite :)
[](https://github.com/gjoseph92)
### gjoseph92 commented on Mar 9, 2022
[](https://github.com/gjoseph92)
[gjoseph92](https://github.com/gjoseph92)
[on Mar 9, 2022](https://github.com/dask/distributed/issues/5889#issuecomment-1063213672)
Collaborator
As someone who prefers "absolute in modules, relative in tests" (or frankly just absolute everywhere), seeing a PR showing the opposite would make me happy :)
[fjetter](https://github.com/fjetter)
mentioned this
[on Mar 10, 2022](https://github.com/dask/distributed/issues/5889#event-1172877021)
- [absolufy-imports - No relative - PEP8 \#5924](https://github.com/dask/distributed/pull/5924)
[jsignell](https://github.com/jsignell)
mentioned this
[on Mar 10, 2022](https://github.com/dask/distributed/issues/5889#event-1172888607)
- [absolufy-imports - No relative - PEP8 dask/dask\#8796](https://github.com/dask/dask/pull/8796)
[](https://github.com/jsignell)
### jsignell commented on Mar 10, 2022
[](https://github.com/jsignell)
[jsignell](https://github.com/jsignell)
[on Mar 10, 2022](https://github.com/dask/distributed/issues/5889#issuecomment-1064347728)
Member
@dask/maintenance if anyone has issues with enforcing absolute imports to comply with pep8 please speak up\!
[](https://github.com/jakirkham)
### jakirkham commented on Mar 13, 2022
[](https://github.com/jakirkham)
[jakirkham](https://github.com/jakirkham)
[on Mar 13, 2022](https://github.com/dask/distributed/issues/5889#issuecomment-1066012544)
Member
Also prefer absolute imports and like that there is tooling to make that simple. Would be good to make sure we have a CI check for it.
[](https://github.com/jacobtomlinson)
### jacobtomlinson commented on Mar 14, 2022
[](https://github.com/jacobtomlinson)
[jacobtomlinson](https://github.com/jacobtomlinson)
[on Mar 14, 2022](https://github.com/dask/distributed/issues/5889#issuecomment-1066737000)
Member
I've never really thought about my preference until this conversation, I tend to just copy whatever already exists. However looking at [\#5917](https://github.com/dask/distributed/pull/5917) and seeing things like `from ....scheduler import ALL_TASK_STATES` I think I would be in favour of enforcing absolute imports everywhere, relative with multiple levels of `.` is super hard to parse mentally.
Doing it in `pre-commit` (and therefore checking in CI) would be awesome.
[crusaderky](https://github.com/crusaderky)
closed this as [completed](https://github.com/dask/distributed/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted)in [\#5924](https://github.com/dask/distributed/pull/5924)
[on Mar 14, 2022](https://github.com/dask/distributed/issues/5889#event-6235308889)
[](https://github.com/crusaderky)
### crusaderky commented on Mar 14, 2022
[](https://github.com/crusaderky)
[crusaderky](https://github.com/crusaderky)
[on Mar 14, 2022](https://github.com/dask/distributed/issues/5889#issuecomment-1066811344)
· edited by [jsignell](https://github.com/jsignell)
Edits
Collaborator
Matching PRs in our other projects:
- [absolufy-imports - No relative - PEP8 dask\#8796](https://github.com/dask/dask/pull/8796)
- [Add absolufy-imports to CI zict\#66](https://github.com/dask/zict/pull/66)
👍React with 👍1
jakirkham
[jakirkham](https://github.com/jakirkham)
mentioned this
[on Mar 14, 2022](https://github.com/dask/distributed/issues/5889#event-1173605197)
- [Add absolufy-imports to CI dask/dask\#8803](https://github.com/dask/dask/pull/8803)
[jsignell](https://github.com/jsignell)
added a commit that references this issue
[on Mar 15, 2022](https://github.com/dask/distributed/issues/5889#event-6246100649)
[absolufy-imports - No relative - PEP8 (](https://github.com/dask/dask/commit/cccb9d8d8e33a891396b1275c2448c352ef40c27)[\#8796](https://github.com/dask/dask/pull/8796))
...
Verified
[cccb9d8](https://github.com/dask/dask/commit/cccb9d8d8e33a891396b1275c2448c352ef40c27)
[keewis](https://github.com/keewis)
mentioned this
[on Oct 31, 2022](https://github.com/dask/distributed/issues/5889#event-1226027879)
- [absolufy-imports - No relative imports - PEP8 pydata/xarray\#7204](https://github.com/pydata/xarray/pull/7204)
[Sign up for free](https://github.com/signup?return_to=https://github.com/dask/distributed/issues/5889) **to join this conversation on GitHub.** Already have an account? [Sign in to comment](https://github.com/login?return_to=https://github.com/dask/distributed/issues/5889)
## Metadata
## Metadata
### Assignees
No one assigned
### Labels
No labels
No labels
### Type
No type
### Projects
No projects
### Milestone
No milestone
### Relationships
None yet
### Development
Code with agent mode
Select code repository
- [absolufy-importsdask/distributed](https://github.com/dask/distributed/pull/5917)
- [absolufy-imports - No relative - PEP8dask/distributed](https://github.com/dask/distributed/pull/5924)
### Participants
[](https://github.com/jacobtomlinson)[](https://github.com/jakirkham)[](https://github.com/gjoseph92)[](https://github.com/jsignell)[](https://github.com/ian-r-rose)
\+3
## Issue actions
## Footer
© 2025 GitHub, Inc.
### Footer navigation
- [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
- [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
- [Security](https://github.com/security)
- [Status](https://www.githubstatus.com/)
- [Docs](https://docs.github.com/)
- [Contact](https://support.github.com/?tags=dotcom-footer)
- Manage cookies
- Do not share my personal information
You can’t perform that action at this time.
\[Style\] Absolute vs Relative imports · Issue \#5889 · dask/distributed |
| Readable Markdown | null |
| Shard | 174 (laksa) |
| Root Hash | 6325672905007345774 |
| Unparsed URL | com,github!/dask/distributed/issues/5889 s443 |