jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1237462?usp=email )

Change subject: isort: allow skipping add future annotation imports per file
......................................................................

isort: allow skipping add future annotation imports per file

- Move `add_imports` setting from pyproject.toml to pre-commit-config file
- Exclude `pywikibot/config.py` from default isort processing
- Add a new isort hook for specific files (`pwb.py` and `config.py`)
  where future annotations are not added
- Move copyright comments to the top of these files to preserve
  import section order by isort

Bug: T416667
Change-Id: I5253ccf68f248a92d94a6e6d347b1e54e4cc3525
---
M .pre-commit-config.yaml
M pwb.py
M pyproject.toml
M pywikibot/config.py
4 files changed, 17 insertions(+), 12 deletions(-)

Approvals:
  jenkins-bot: Verified
  Xqt: Looks good to me, approved




diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 7262cfe..c5af6e9 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -90,7 +90,13 @@
     rev: 7.0.0
     hooks:
       - id: isort
-        exclude: ^pwb\.py$
+        name: isort
+        args:
+          - -a from __future__ import annotations
+        exclude: ^(pwb|pywikibot/config)\.py$
+      - id: isort
+        name: isort (skip future annotations)
+        files: ^(pwb|pywikibot/config)\.py$
   - repo: https://github.com/jshwi/docsig
     rev: v0.77.0
     hooks:
diff --git a/pwb.py b/pwb.py
index e8c5ed6..02d55dd 100755
--- a/pwb.py
+++ b/pwb.py
@@ -1,13 +1,13 @@
 #!/usr/bin/env python3
+#
+# (C) Pywikibot team, 2022-2026
+#
+# Distributed under the terms of the MIT license.
+#
 """PWB caller script to invoke the :mod:`pywikibot.scripts.wrapper` script.

 .. versionadded:: 8.0
 """
-#
-# (C) Pywikibot team, 2022-2025
-#
-# Distributed under the terms of the MIT license.
-#
 import runpy
 import sys

diff --git a/pyproject.toml b/pyproject.toml
index 9ff96b1..8269afc 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -173,7 +173,6 @@

 [tool.isort]
 py_version = 39
-add_imports = ["from __future__ import annotations"]
 atomic = true
 ensure_newline_before_comments = true
 force_grid_wrap = 0
diff --git a/pywikibot/config.py b/pywikibot/config.py
index 7b70c59..e5c60e5 100644
--- a/pywikibot/config.py
+++ b/pywikibot/config.py
@@ -1,3 +1,8 @@
+#
+# (C) Pywikibot team, 2003-2026
+#
+# Distributed under the terms of the MIT license.
+#
 """Module to define pywikibot configuration default and user preferences.

 User preferences are loaded from a python file called `user-config.py`,
@@ -32,11 +37,6 @@
    Editor settings has been revised. *editor* variable is None by
    default. Editor detection functions were moved to :mod:`editor`.
 """
-#
-# (C) Pywikibot team, 2003-2026
-#
-# Distributed under the terms of the MIT license.
-#
 from __future__ import annotations

 import collections

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1237462?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I5253ccf68f248a92d94a6e6d347b1e54e4cc3525
Gerrit-Change-Number: 1237462
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to