Skip to content

Commit

Permalink
Merge branch 'main' into revert-starmap-list
Browse files Browse the repository at this point in the history
  • Loading branch information
echoix authored Feb 2, 2025
2 parents d8bce16 + 09f9235 commit 9340a1e
Show file tree
Hide file tree
Showing 107 changed files with 270 additions and 431 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
ignore =
# whitespace before ':' (Black)
E203,
# E501 line too long
E501,
# line break before binary operator (Black)
W503,

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/additional_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
exclude: mswindows .*\.bat .*/testsuite/data/.*

- name: Set up Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: '3.10'

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: '3.x'
- name: Install non-Python dependencies
Expand All @@ -57,7 +57,7 @@ jobs:
if: ${{ matrix.language == 'c-cpp' }}

- name: Initialize CodeQL
uses: github/codeql-action/init@f6091c0113d1dcf9b98e269ee48e8a7e51b7bdd4 # v3.28.5
uses: github/codeql-action/init@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql/codeql-config.yml
Expand All @@ -82,6 +82,6 @@ jobs:
run: .github/workflows/build_ubuntu-22.04.sh "${HOME}/install"

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@f6091c0113d1dcf9b98e269ee48e8a7e51b7bdd4 # v3.28.5
uses: github/codeql-action/analyze@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion .github/workflows/create_release_draft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
ref: ${{ github.ref }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: '3.11'
- name: Create output directory
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Set up Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: ${{ matrix.python-version }}
cache: pip
Expand Down
31 changes: 11 additions & 20 deletions .github/workflows/python-code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,14 @@ jobs:
# renovate: datasource=python-version depName=python
PYTHON_VERSION: "3.13"
MIN_PYTHON_VERSION: "3.9"
# renovate: datasource=pypi depName=black
BLACK_VERSION: "24.10.0"
# renovate: datasource=pypi depName=flake8
FLAKE8_VERSION: "7.1.1"
# renovate: datasource=pypi depName=pylint
PYLINT_VERSION: "3.3.4"
# renovate: datasource=pypi depName=bandit
BANDIT_VERSION: "1.8.2"
# renovate: datasource=pypi depName=ruff
RUFF_VERSION: "0.9.3"
RUFF_VERSION: "0.9.4"

runs-on: ${{ matrix.os }}
permissions:
Expand All @@ -59,7 +57,7 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Set up Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip
Expand All @@ -73,6 +71,14 @@ jobs:
continue-on-error: true
- name: Run Ruff (apply fixes for suggestions)
run: ruff check . --preview --fix --unsafe-fixes
- name: Run `ruff format` showing diff without failing
continue-on-error: true
if: ${{ !cancelled() }}
run: ruff format --diff
- name: Run `ruff format` fixing files
# Run `ruff format` even when `ruff check` fixed files: fixes can require formatting
if: ${{ !cancelled() }}
run: ruff format --diff
- name: Create and uploads code suggestions to apply for Ruff
# Will fail fast here if there are changes required
id: diff-ruff
Expand All @@ -84,21 +90,6 @@ jobs:
# To keep repo's file structure in formatted changes artifact
extra-upload-changes: pyproject.toml

- name: Install Black only
run: pip install black[jupyter]==${{ env.BLACK_VERSION }}

- name: Run Black
run: black .

- name: Create and uploads code suggestions to apply for Black
# Will fail fast here if there are changes required
id: diff-black
uses: ./.github/actions/create-upload-suggestions
with:
tool-name: black
# To keep repo's file structure in formatted changes artifact
extra-upload-changes: .clang-format

- name: Install non-Python dependencies
run: |
sudo apt-get update -y
Expand Down Expand Up @@ -137,7 +128,7 @@ jobs:
path: bandit.sarif

- name: Upload SARIF File into Security Tab
uses: github/codeql-action/upload-sarif@f6091c0113d1dcf9b98e269ee48e8a7e51b7bdd4 # v3.28.5
uses: github/codeql-action/upload-sarif@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8
with:
sarif_file: bandit.sarif

Expand Down
13 changes: 3 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,17 @@ repos:
)
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.9.3
rev: v0.9.4
hooks:
# Run the linter.
- id: ruff
args: [--fix, --preview]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.44.0
hooks:
- id: markdownlint-fix
# Using this mirror lets us use mypyc-compiled black, which is about 2x faster
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.10.0
hooks:
- id: black-jupyter
exclude: |
(?x)^(
python/libgrass_interface_generator/
)
- repo: https://github.com/pycqa/flake8
rev: 7.1.1
hooks:
Expand Down
1 change: 1 addition & 0 deletions db/db.describe/testsuite/test_dbdescribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@author: lucadelu
"""

import json

from grass.gunittest.case import TestCase
Expand Down
42 changes: 21 additions & 21 deletions general/g.version/tests/g_version_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,36 @@
def test_g_version_no_flag(session):
"""Test that g.version output contains the word 'GRASS'."""
output = gs.read_command("g.version", env=session.env).strip()
assert (
"GRASS" in output
), "Expected 'GRASS' in g.version output, but it was not found."
assert "GRASS" in output, (
"Expected 'GRASS' in g.version output, but it was not found."
)


def test_c_flag(session):
"""Test the output of g.version -c for Copyright and License Statement."""
expected_text = "Copyright and License Statement"
output = gs.read_command("g.version", flags="c", env=session.env).strip()
assert (
expected_text in output
), f"Expected '{expected_text}' in g.version -c output, but got: '{output}'"
assert expected_text in output, (
f"Expected '{expected_text}' in g.version -c output, but got: '{output}'"
)


def test_e_flag(session):
"""Test that g.version -e contains the expected keys."""
expected_keys = ["PROJ:", "GDAL/OGR:", "SQLite:"]
output = gs.read_command("g.version", flags="e", env=session.env).strip()
for key in expected_keys:
assert (
key in output
), f"Expected key '{key}' in g.version -e output, but it was not found."
assert key in output, (
f"Expected key '{key}' in g.version -e output, but it was not found."
)


def test_b_flag(session):
"""Test that g.version -b output contains the word 'GRASS'."""
output = gs.read_command("g.version", flags="b", env=session.env).strip()
assert (
"GRASS" in output
), "Expected 'GRASS' in g.version -b output, but it was not found."
assert "GRASS" in output, (
"Expected 'GRASS' in g.version -b output, but it was not found."
)


def test_g_flag(session):
Expand All @@ -48,19 +48,19 @@ def test_g_flag(session):
]
output = gs.parse_command("g.version", flags="g", env=session.env)
for key in expected_keys:
assert (
key in output
), f"Expected key '{key}' in g.version -g output, but it was not found."
assert key in output, (
f"Expected key '{key}' in g.version -g output, but it was not found."
)


def test_r_flag(session):
"""Test that g.version -r contains the expected keys."""
expected_texts = ["libgis revision:", "libgis date:"]
output = gs.read_command("g.version", flags="r", env=session.env).strip()
for text in expected_texts:
assert (
text in output
), f"Expected key '{text}' in g.version -r output, but it was not found."
assert text in output, (
f"Expected key '{text}' in g.version -r output, but it was not found."
)


def test_x_flag(session):
Expand All @@ -78,6 +78,6 @@ def curly_brackets_paired(text):
return False
return counter == 0

assert curly_brackets_paired(
output
), "Curly brackets are not properly paired in the g.version -x output."
assert curly_brackets_paired(output), (
"Curly brackets are not properly paired in the g.version -x output."
)
5 changes: 3 additions & 2 deletions gui/wxpython/animation/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,9 @@ def Load(self, force=False, bgcolor=(255, 255, 255), nprocs=4):
"""
Debug.msg(
2,
"BitmapProvider.Load: "
"force={f}, bgcolor={b}, nprocs={n}".format(f=force, b=bgcolor, n=nprocs),
"BitmapProvider.Load: force={f}, bgcolor={b}, nprocs={n}".format(
f=force, b=bgcolor, n=nprocs
),
)
cmds = []
regions = []
Expand Down
11 changes: 4 additions & 7 deletions gui/wxpython/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,9 +816,9 @@ def _internalSettings(self):
)

self.internalSettings["display"]["driver"]["choices"] = ["cairo", "png"]
self.internalSettings["display"]["statusbarMode"][
"choices"
] = None # set during MapFrame init
self.internalSettings["display"]["statusbarMode"]["choices"] = (
None # set during MapFrame init
)
self.internalSettings["display"]["mouseWheelZoom"]["choices"] = (
_("Zoom and recenter"),
_("Zoom to mouse cursor"),
Expand Down Expand Up @@ -998,10 +998,7 @@ def SaveToFile(self, settings=None):
raise GException(e)
except Exception as e:
raise GException(
_(
"Writing settings to file <%(file)s> failed."
"\n\nDetails: %(detail)s"
)
_("Writing settings to file <%(file)s> failed.\n\nDetails: %(detail)s")
% {"file": self.filePath, "detail": e}
)
return self.filePath
Expand Down
1 change: 0 additions & 1 deletion gui/wxpython/core/testsuite/test_gcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def recv(self):


class Recv_SomeTest(TestCase):

@xfail_windows
def test_decode(self):
"""
Expand Down
5 changes: 1 addition & 4 deletions gui/wxpython/core/toolboxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,7 @@ def getMenudataFile(userRootFile, newFile, fallback):
generateNew = True
_debug(
2,
(
"toolboxes.getMenudataFile: only one of the user "
"defined files"
),
("toolboxes.getMenudataFile: only one of the user defined files"),
)
else:
# if newer files -> generate new
Expand Down
3 changes: 1 addition & 2 deletions gui/wxpython/datacatalog/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ def _doLayout(self):
dialogSizer.Add(optionsSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=10)
helptext = StaticText(
self.panel,
label="For more reprojection options,"
" please see {module}".format(
label="For more reprojection options, please see {module}".format(
module="r.proj" if self.etype == "raster" else "v.proj"
),
)
Expand Down
16 changes: 7 additions & 9 deletions gui/wxpython/dbmgr/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ def LoadData(self, layer, columns=None, where=None, sql=None):
GError(
parent=self,
message=_(
"Column <%(column)s> not found in "
"in the table <%(table)s>."
"Column <%(column)s> not found in in the table <%(table)s>."
)
% {"column": col, "table": tableName},
)
Expand Down Expand Up @@ -1642,10 +1641,7 @@ def OnDataItemAdd(self, event):
try:
if cat in tlist.itemCatsMap.values():
raise ValueError(
_(
"Record with category number %d "
"already exists in the table."
)
_("Record with category number %d already exists in the table.")
% cat
)

Expand Down Expand Up @@ -2227,9 +2223,11 @@ def ValidateSelectStatement(self, statement):

tablelen = len(self.dbMgrData["mapDBInfo"].layers[self.selLayer]["table"])

if statement[index + 1 : index + 6].lower() != "from " or statement[
index + 6 : index + 6 + tablelen
] != "%s" % (self.dbMgrData["mapDBInfo"].layers[self.selLayer]["table"]):
if (
statement[index + 1 : index + 6].lower() != "from "
or statement[index + 6 : index + 6 + tablelen]
!= "%s" % (self.dbMgrData["mapDBInfo"].layers[self.selLayer]["table"])
):
return None

if len(statement[index + 7 + tablelen :]) > 0:
Expand Down
Loading

0 comments on commit 9340a1e

Please sign in to comment.