Skip to content

Conversation

@Flamefire
Copy link

Type of Changes

Type
✨ New feature

Description

Add support for --known-first-party similar to --known-third-party:
Force import order to recognize a module as part of a first party library.

Based on #10802 as otherwise tests would fail

Fix regression in 6ce6032:
In `__init__` the options are not parsed yet and hence will always be
the defaults.
@Flamefire Flamefire force-pushed the first-party-imports branch from 4852254 to bd160ae Compare January 6, 2026 10:02
@Flamefire Flamefire force-pushed the first-party-imports branch from bd160ae to 070dac1 Compare January 6, 2026 13:03
@Flamefire Flamefire changed the title Add support for isort: known-first-party Add support for isort option --known-first-party Jan 6, 2026
@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.98%. Comparing base (4f6c241) to head (710916d).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #10803   +/-   ##
=======================================
  Coverage   95.98%   95.98%           
=======================================
  Files         176      176           
  Lines       19564    19567    +3     
=======================================
+ Hits        18779    18782    +3     
  Misses        785      785           
Files with missing lines Coverage Δ
pylint/checkers/imports.py 94.91% <100.00%> (+0.03%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Pierre-Sassoulas Is this option something we want to add?

@github-actions

This comment has been minimized.

@Flamefire Flamefire force-pushed the first-party-imports branch from f161aa6 to 288f0f7 Compare January 7, 2026 09:21
@Flamefire Flamefire force-pushed the first-party-imports branch from 270b3bd to 710916d Compare January 7, 2026 09:23
@Flamefire
Copy link
Author

Flamefire commented Jan 7, 2026

Motivation for me was that we have a project that uses a test folder and hence import test.utils etc. but test is a Python stdlib package: PyCQA/isort#2383

Rather than doing a large-scale refactoring adding this exception is the easiest way out.

It would be even better if PyLint would understand the isort config (in setup.cfg) directly so one doesn't has to duplicate it.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉

This comment was generated for commit 710916d

With the fix of honoring the config the import is now correctly
identified using the overwrite `known-standard-library=_string`
Similar to known-third-party this recognizes modules as first party modules.
@Flamefire Flamefire force-pushed the first-party-imports branch from 710916d to ceba49f Compare January 9, 2026 07:41
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 this pull request may close these issues.

2 participants