Skip to content

Commit 9278c30

Browse files
CI(deps): Update ruff to v0.14.0 (OSGeo#6450)
* CI(deps): Update ruff to v0.14.0 * CQ: Fix new F401 patterns in grass.temporal.core psycopg2 imports * wxgui: Remove import wx.aui from gui_core/infobar.py * wxgui: Remove unused imports wx.adv and wx.combo when another import occurs * wxgui: Remove import wx.aui from lmgr/workspace.py * wxgui: Remove unused import wx.html from wxgui.py --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Edouard Choinière <[email protected]>
1 parent 0620f1e commit 9278c30

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

.github/workflows/python-code-quality.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
# renovate: datasource=pypi depName=bandit
3737
BANDIT_VERSION: "1.8.6"
3838
# renovate: datasource=pypi depName=ruff
39-
RUFF_VERSION: "0.13.2"
39+
RUFF_VERSION: "0.14.0"
4040

4141
runs-on: ${{ matrix.os }}
4242
permissions:

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ repos:
4242
)
4343
- repo: https://github.com/astral-sh/ruff-pre-commit
4444
# Ruff version.
45-
rev: v0.13.2
45+
rev: v0.14.0
4646
hooks:
4747
# Run the linter.
4848
- id: ruff-check

gui/wxpython/gui_core/infobar.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import sys
2020
import wx
21-
import wx.aui
2221

2322
try:
2423
import wx.lib.agw.infobar as IB

gui/wxpython/gui_core/widgets.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,8 @@
6565
from wx.lib.wordwrap import wordwrap
6666

6767
if wxPythonPhoenix:
68-
import wx.adv
6968
from wx.adv import OwnerDrawnComboBox
7069
else:
71-
import wx.combo
7270
from wx.combo import OwnerDrawnComboBox
7371
try:
7472
import wx.lib.agw.flatnotebook as FN

gui/wxpython/lmgr/workspace.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from pathlib import Path
2222

2323
import wx
24-
import wx.aui
2524

2625
from core.settings import UserSettings
2726
from core.gcmd import RunCommand, GError, GMessage

gui/wxpython/wxgui.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
# we get annoying "Debug: Adding duplicate image handler for 'Windows bitmap file'"
3737
# during start up, remove when not needed
3838
import wx.adv
39-
import wx.html
4039

4140
try:
4241
import wx.lib.agw.advancedsplash as SC

python/grass/temporal/core.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@
3232

3333
from __future__ import annotations
3434

35-
# import traceback
35+
import atexit
3636
import os
37+
import sqlite3
38+
from datetime import datetime
39+
from importlib.util import find_spec
3740
from pathlib import Path
3841

3942
import grass.script as gs
@@ -42,22 +45,24 @@
4245

4346
from .c_libraries_interface import CLibrariesInterface
4447

45-
# Import all supported database backends
46-
# Ignore import errors since they are checked later
4748

48-
import sqlite3
49+
# Import all supported database backends (sqlite3 imported above)
50+
# Ignore import errors since they are checked later
4951

52+
db_errors: tuple[type[sqlite3.Error], type[psycopg2.Error]] | tuple[type[sqlite3.Error]]
5053
# Postgresql is optional, existence is checked when needed
51-
try:
52-
import psycopg2
54+
if find_spec("psycopg2") is not None and find_spec("psycopg2.extras") is not None:
55+
# Following explanations on how importing submodules work
56+
# from ruff's v0.13.3 new F401 handling https://github.com/astral-sh/ruff/pull/20200
57+
# importing "psycopg2.extras" actually makes an "import psycopg2",
58+
# making the members of the form `psycopg2.*` available, and then also imports the
59+
# extras and makes available the members of the form `psycopg2.extras.*`.
5360
import psycopg2.extras
5461

5562
db_errors = (sqlite3.Error, psycopg2.Error)
56-
except ImportError:
63+
else:
5764
db_errors = (sqlite3.Error,)
5865

59-
import atexit
60-
from datetime import datetime
6166

6267
###############################################################################
6368

0 commit comments

Comments
 (0)