diff --git a/db/db.columns/testsuite/test_dbcolumns.py b/db/db.columns/testsuite/test_dbcolumns.py index 11f30b80df9..bbb42c3d9a9 100644 --- a/db/db.columns/testsuite/test_dbcolumns.py +++ b/db/db.columns/testsuite/test_dbcolumns.py @@ -1,6 +1,6 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test -from grass.script.core import read_command, parse_command +from grass.script.core import parse_command, read_command output_plain = """cat OBJECTID diff --git a/db/db.connect/testsuite/test_db_connect.py b/db/db.connect/testsuite/test_db_connect.py index e5c4e23885d..2bebefad27f 100644 --- a/db/db.connect/testsuite/test_db_connect.py +++ b/db/db.connect/testsuite/test_db_connect.py @@ -1,6 +1,6 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test -from grass.script.core import read_command, parse_command +from grass.script.core import parse_command, read_command class TestDbConnect(TestCase): diff --git a/display/d.mon/render_cmd.py b/display/d.mon/render_cmd.py index 7f1d2d54dbc..f3f92ce670d 100644 --- a/display/d.mon/render_cmd.py +++ b/display/d.mon/render_cmd.py @@ -1,13 +1,13 @@ #!/usr/bin/env python3 +import glob import os import sys -import glob import tempfile from pathlib import Path +from grass.exceptions import CalledModuleError from grass.script import core as grass from grass.script import task as gtask -from grass.exceptions import CalledModuleError non_rendering_modules = ( "d.colorlist", diff --git a/display/d.text/test.py b/display/d.text/test.py index dd8836938a5..66251e744e9 100755 --- a/display/d.text/test.py +++ b/display/d.text/test.py @@ -2,8 +2,8 @@ # Author: Owen Smith - Rewritten from test.pl by Huidae Cho # Run: d.mon start=wx0 && ./test.py | d.text at=0,100 import math -from pathlib import Path import re +from pathlib import Path # Quiet black syntax checking for fonts and colors to keep the code printed to # the display vertically short. diff --git a/general/g.findfile/tests/test_g_findfile.py b/general/g.findfile/tests/test_g_findfile.py index 9297ad2468e..a0b83e63d60 100644 --- a/general/g.findfile/tests/test_g_findfile.py +++ b/general/g.findfile/tests/test_g_findfile.py @@ -1,8 +1,8 @@ import os -import pytest from pathlib import Path import grass.script as gs +import pytest @pytest.fixture(scope="module") diff --git a/lib/gis/tests/lib_gis_env_test.py b/lib/gis/tests/lib_gis_env_test.py index 5a2a3607360..fd88470d198 100644 --- a/lib/gis/tests/lib_gis_env_test.py +++ b/lib/gis/tests/lib_gis_env_test.py @@ -1,9 +1,9 @@ """Test environment and GIS environment functions""" +import json import os import subprocess import sys -import json from textwrap import dedent import pytest diff --git a/lib/gis/tests/lib_gis_parser_json_test.py b/lib/gis/tests/lib_gis_parser_json_test.py index ff60d99c2aa..4eea69086cd 100644 --- a/lib/gis/tests/lib_gis_parser_json_test.py +++ b/lib/gis/tests/lib_gis_parser_json_test.py @@ -2,7 +2,6 @@ import pytest - from grass.exceptions import CalledModuleError diff --git a/lib/gis/testsuite/gis_lib_env_test.py b/lib/gis/testsuite/gis_lib_env_test.py index fafc00a37ed..4845a888429 100644 --- a/lib/gis/testsuite/gis_lib_env_test.py +++ b/lib/gis/testsuite/gis_lib_env_test.py @@ -3,8 +3,8 @@ @author Soeren Gebbert """ -from grass.gunittest.case import TestCase import grass.lib.gis as libgis +from grass.gunittest.case import TestCase class GisLibraryTestEnv(TestCase): diff --git a/lib/gis/testsuite/gis_lib_str_color.py b/lib/gis/testsuite/gis_lib_str_color.py index c784ab95d39..754320f4aba 100644 --- a/lib/gis/testsuite/gis_lib_str_color.py +++ b/lib/gis/testsuite/gis_lib_str_color.py @@ -5,11 +5,10 @@ from ctypes import byref, c_int +import grass.lib.gis as libgis from grass.gunittest.case import TestCase from grass.gunittest.main import test -import grass.lib.gis as libgis - class StringToColorTestCase(TestCase): """Test C function G_str_to_color() from gis library""" diff --git a/lib/gis/testsuite/gis_lib_tokenize.py b/lib/gis/testsuite/gis_lib_tokenize.py index 89c70e5e722..73e0707aed1 100644 --- a/lib/gis/testsuite/gis_lib_tokenize.py +++ b/lib/gis/testsuite/gis_lib_tokenize.py @@ -3,11 +3,10 @@ @author Vaclav Petras """ +import grass.lib.gis as libgis from grass.gunittest.case import TestCase from grass.gunittest.main import test -import grass.lib.gis as libgis - # TODO: add tests for content (now testing only number of items) diff --git a/lib/gis/testsuite/test_gis_lib_getl.py b/lib/gis/testsuite/test_gis_lib_getl.py index 1a32eb6a2a6..925354109d7 100644 --- a/lib/gis/testsuite/test_gis_lib_getl.py +++ b/lib/gis/testsuite/test_gis_lib_getl.py @@ -3,8 +3,8 @@ @author Vaclav Petras """ -import os import ctypes +import os import unittest from pathlib import Path diff --git a/lib/gis/testsuite/test_parser_json.py b/lib/gis/testsuite/test_parser_json.py index dcbc7f1698d..1a6847cc8dd 100644 --- a/lib/gis/testsuite/test_parser_json.py +++ b/lib/gis/testsuite/test_parser_json.py @@ -8,11 +8,12 @@ @author Soeren Gebbert """ +import json import subprocess + from grass.gunittest.case import TestCase from grass.gunittest.utils import xfail_windows from grass.script import decode -import json class TestParserJson(TestCase): diff --git a/lib/imagery/testsuite/test_imagery_find.py b/lib/imagery/testsuite/test_imagery_find.py index 72e99bc2776..32e0bdf5390 100644 --- a/lib/imagery/testsuite/test_imagery_find.py +++ b/lib/imagery/testsuite/test_imagery_find.py @@ -14,19 +14,17 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test - -from grass.script.core import tempname -from grass.pygrass import utils -from grass.pygrass.gis import Mapset - from grass.lib.gis import G_mapset_path from grass.lib.imagery import ( + I_SIGFILE_TYPE_LIBSVM, I_SIGFILE_TYPE_SIG, I_SIGFILE_TYPE_SIGSET, - I_SIGFILE_TYPE_LIBSVM, I_find_signature, I_find_signature2, ) +from grass.pygrass import utils +from grass.pygrass.gis import Mapset +from grass.script.core import tempname class FindSignatureTestCase(TestCase): diff --git a/lib/imagery/testsuite/test_imagery_sigfile.py b/lib/imagery/testsuite/test_imagery_sigfile.py index 2c6a927d634..dcc582c11fe 100644 --- a/lib/imagery/testsuite/test_imagery_sigfile.py +++ b/lib/imagery/testsuite/test_imagery_sigfile.py @@ -9,36 +9,34 @@ for details """ -import stat import ctypes import os import shutil +import stat from pathlib import Path from grass.gunittest.case import TestCase from grass.gunittest.main import test - -from grass.script.core import tempname -from grass.pygrass import utils -from grass.pygrass.gis import Mapset - from grass.lib.gis import G_mapset_path -from grass.lib.raster import Rast_write_semantic_label from grass.lib.imagery import ( - Signature, - Ref, - I_init_signatures, - I_new_signature, + I_add_file_to_group_ref, I_fopen_signature_file_new, - I_write_signatures, I_fopen_signature_file_old, - I_read_signatures, - I_sort_signatures_by_semantic_label, + I_free_group_ref, I_free_signatures, I_init_group_ref, - I_add_file_to_group_ref, - I_free_group_ref, + I_init_signatures, + I_new_signature, + I_read_signatures, + I_sort_signatures_by_semantic_label, + I_write_signatures, + Ref, + Signature, ) +from grass.lib.raster import Rast_write_semantic_label +from grass.pygrass import utils +from grass.pygrass.gis import Mapset +from grass.script.core import tempname class SignatureFileTestCase(TestCase): diff --git a/lib/imagery/testsuite/test_imagery_signature_management.py b/lib/imagery/testsuite/test_imagery_signature_management.py index e180090c655..b7c23e87a12 100644 --- a/lib/imagery/testsuite/test_imagery_signature_management.py +++ b/lib/imagery/testsuite/test_imagery_signature_management.py @@ -9,40 +9,38 @@ for details """ +import ctypes import os import shutil -import ctypes +from pathlib import Path +import grass.script as gs from grass.gunittest.case import TestCase from grass.gunittest.main import test from grass.gunittest.utils import xfail_windows - -from grass.script.core import tempname -import grass.script as gs -from grass.pygrass import utils -from grass.pygrass.gis import Mapset, make_mapset -from pathlib import Path - from grass.lib.gis import ( - G_mapset_path, - G_make_mapset, - G_reset_mapsets, GNAME_MAX, HOST_DIRSEP, + G_make_mapset, + G_mapset_path, + G_reset_mapsets, ) from grass.lib.imagery import ( + I_SIGFILE_TYPE_LIBSVM, I_SIGFILE_TYPE_SIG, I_SIGFILE_TYPE_SIGSET, - I_SIGFILE_TYPE_LIBSVM, I_find_signature, - I_signatures_remove, - I_signatures_copy, - I_signatures_rename, - I_signatures_list_by_type, I_free_signatures_list, I_get_signatures_dir, I_make_signatures_dir, + I_signatures_copy, + I_signatures_list_by_type, + I_signatures_remove, + I_signatures_rename, ) +from grass.pygrass import utils +from grass.pygrass.gis import Mapset, make_mapset +from grass.script.core import tempname class GetSignaturesDirTestCase(TestCase): diff --git a/lib/imagery/testsuite/test_imagery_sigsetfile.py b/lib/imagery/testsuite/test_imagery_sigsetfile.py index fd8d6845dbf..04be4985004 100644 --- a/lib/imagery/testsuite/test_imagery_sigsetfile.py +++ b/lib/imagery/testsuite/test_imagery_sigsetfile.py @@ -9,37 +9,35 @@ for details """ -import stat import ctypes import os import shutil +import stat from pathlib import Path from grass.gunittest.case import TestCase from grass.gunittest.main import test - -from grass.script.core import tempname -from grass.pygrass import utils -from grass.pygrass.gis import Mapset - from grass.lib.gis import G_mapset_path -from grass.lib.raster import Rast_write_semantic_label from grass.lib.imagery import ( - SigSet, + I_add_file_to_group_ref, + I_fopen_sigset_file_new, + I_fopen_sigset_file_old, + I_free_group_ref, + I_init_group_ref, I_InitSigSet, I_NewClassSig, I_NewSubSig, - I_WriteSigSet, I_ReadSigSet, I_SortSigSetBySemanticLabel, - I_fopen_sigset_file_new, - I_fopen_sigset_file_old, + I_WriteSigSet, Ref, - I_init_group_ref, - I_add_file_to_group_ref, - I_free_group_ref, ReturnString, + SigSet, ) +from grass.lib.raster import Rast_write_semantic_label +from grass.pygrass import utils +from grass.pygrass.gis import Mapset +from grass.script.core import tempname class SigSetFileTestCase(TestCase): diff --git a/lib/init/grass.py b/lib/init/grass.py index 270803ddc81..1e66fa7ce9c 100755 --- a/lib/init/grass.py +++ b/lib/init/grass.py @@ -57,7 +57,6 @@ import tempfile import unicodedata import uuid - from pathlib import Path from typing import TYPE_CHECKING, Literal, NoReturn diff --git a/lib/init/testsuite/test_grass_tmp_mapset.py b/lib/init/testsuite/test_grass_tmp_mapset.py index e091a1b51b0..65bcaf75f8f 100644 --- a/lib/init/testsuite/test_grass_tmp_mapset.py +++ b/lib/init/testsuite/test_grass_tmp_mapset.py @@ -14,11 +14,10 @@ for details. """ -import unittest import os import shutil import subprocess - +import unittest # Note that unlike rest of GRASS, here we are using unittest package # directly. The grass.gunittest machinery for mapsets is not needed here. diff --git a/lib/raster/tests/lib_raster_reclass_test.py b/lib/raster/tests/lib_raster_reclass_test.py index dca19125644..06acf8aae78 100644 --- a/lib/raster/tests/lib_raster_reclass_test.py +++ b/lib/raster/tests/lib_raster_reclass_test.py @@ -1,13 +1,13 @@ import os -from pathlib import Path from io import StringIO +from pathlib import Path import pytest -from grass.script import MaskManager -from grass.tools import Tools from grass.exceptions import CalledModuleError from grass.experimental import MapsetSession +from grass.script import MaskManager +from grass.tools import Tools def test_reclass_as_mask_correct_state(session): diff --git a/lib/raster/testsuite/rast_parse_color_rule.py b/lib/raster/testsuite/rast_parse_color_rule.py index f2d9db51f07..0c6595cea3b 100644 --- a/lib/raster/testsuite/rast_parse_color_rule.py +++ b/lib/raster/testsuite/rast_parse_color_rule.py @@ -10,11 +10,10 @@ for details """ -from ctypes import byref, c_int, c_double +from ctypes import byref, c_double, c_int from grass.gunittest.case import TestCase from grass.gunittest.main import test - from grass.lib.raster import Rast_parse_color_rule, Rast_parse_color_rule_error diff --git a/lib/raster/testsuite/test_raster_metadata.py b/lib/raster/testsuite/test_raster_metadata.py index 43bbfaeea99..dcca6c46717 100644 --- a/lib/raster/testsuite/test_raster_metadata.py +++ b/lib/raster/testsuite/test_raster_metadata.py @@ -14,18 +14,16 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test - -from grass.script.core import tempname -from grass.pygrass.gis import Mapset -from grass.pygrass import utils - from grass.lib.gis import G_remove_misc from grass.lib.raster import ( + Rast_get_semantic_label_or_name, Rast_legal_semantic_label, Rast_read_semantic_label, - Rast_get_semantic_label_or_name, Rast_write_semantic_label, ) +from grass.pygrass import utils +from grass.pygrass.gis import Mapset +from grass.script.core import tempname class RastLegalBandIdTestCase(TestCase): diff --git a/lib/vector/Vlib/testsuite/test_vlib_box.py b/lib/vector/Vlib/testsuite/test_vlib_box.py index 71166d4fd29..f085d33826f 100644 --- a/lib/vector/Vlib/testsuite/test_vlib_box.py +++ b/lib/vector/Vlib/testsuite/test_vlib_box.py @@ -13,8 +13,8 @@ """ import ctypes -import grass.lib.vector as libvect +import grass.lib.vector as libvect from grass.gunittest.case import TestCase from grass.gunittest.main import test diff --git a/lib/vector/Vlib/testsuite/test_vlib_intersect.py b/lib/vector/Vlib/testsuite/test_vlib_intersect.py index 1f62336a809..f2861e6d539 100644 --- a/lib/vector/Vlib/testsuite/test_vlib_intersect.py +++ b/lib/vector/Vlib/testsuite/test_vlib_intersect.py @@ -13,7 +13,6 @@ """ import grass.lib.vector as libvect - from grass.gunittest.case import TestCase from grass.gunittest.main import test diff --git a/locale/grass_po_stats.py b/locale/grass_po_stats.py index db8106d51f5..9c142773257 100644 --- a/locale/grass_po_stats.py +++ b/locale/grass_po_stats.py @@ -22,7 +22,6 @@ import os import subprocess import sys - from pathlib import Path diff --git a/man/build.py b/man/build.py index a7e9f5817c9..a802b818adb 100644 --- a/man/build.py +++ b/man/build.py @@ -103,7 +103,7 @@ def get_files(man_dir, cls=None, ignore_gui=True, extension: str = "html"): def write_header(f: IO, title, ismain=False, body_width="99%", template: str = "html"): if template == "html": - from build_html import header1_tmpl, macosx_tmpl, header2_tmpl + from build_html import header1_tmpl, header2_tmpl, macosx_tmpl else: from build_md import header1_tmpl, header2_tmpl f.write(header1_tmpl.substitute(title=title)) diff --git a/man/build_check.py b/man/build_check.py index 1dc578c56af..f698e1440cb 100644 --- a/man/build_check.py +++ b/man/build_check.py @@ -6,10 +6,10 @@ # Markus Neteler # Glynn Clements -import sys import os +import sys -from build import message_tmpl, get_files, read_file +from build import get_files, message_tmpl, read_file from build_html import man_dir os.chdir(man_dir) diff --git a/man/build_check_rest.py b/man/build_check_rest.py index f9868dfd697..fbdff214542 100644 --- a/man/build_check_rest.py +++ b/man/build_check_rest.py @@ -6,10 +6,10 @@ # Markus Neteler # Glynn Clements -import sys import os +import sys -from build_rest import rest_dir, message_tmpl, rest_files, read_file +from build_rest import message_tmpl, read_file, rest_dir, rest_files os.chdir(rest_dir) diff --git a/man/build_class.py b/man/build_class.py index 822bad6bd3d..a97d6ea8655 100644 --- a/man/build_class.py +++ b/man/build_class.py @@ -6,8 +6,8 @@ # Markus Neteler # Glynn Clements -import sys import os +import sys no_intro_page_classes = ["display", "general", "miscellaneous", "postscript"] @@ -15,19 +15,19 @@ def build_class(ext): if ext == "html": from build_html import ( - modclass_tmpl, - get_desc, desc2_tmpl, - modclass_intro_tmpl, + get_desc, man_dir, + modclass_intro_tmpl, + modclass_tmpl, ) else: from build_md import ( - modclass_tmpl, - get_desc, desc2_tmpl, - modclass_intro_tmpl, + get_desc, man_dir, + modclass_intro_tmpl, + modclass_tmpl, ) os.chdir(man_dir) @@ -74,12 +74,12 @@ def build_class(ext): year = sys.argv[3] from build import ( - to_title, check_for_desc_override, - replace_file, get_files, - write_header, + replace_file, + to_title, write_footer, + write_header, ) build_class("html") diff --git a/man/build_class_graphical.py b/man/build_class_graphical.py index 4b67a69998b..5a6aa5a74ed 100644 --- a/man/build_class_graphical.py +++ b/man/build_class_graphical.py @@ -13,30 +13,27 @@ # ############################################################################# -import sys -import os import fnmatch +import os +import sys +import build_md from build import ( + check_for_desc_override, default_year, + get_files, grass_version, + replace_file, to_title, - get_files, - check_for_desc_override, write_footer, - replace_file, ) - from build_html import ( - header1_tmpl, - modclass_intro_tmpl, get_desc, + header1_tmpl, man_dir, + modclass_intro_tmpl, ) -import build_md - - graphical_index_style = """\