Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: Fix unused-import (F401) #4521

Merged
merged 30 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7092055
t.rast.accumulate: Remove unused SimpleModule import in test_accumula…
echoix Oct 6, 2024
b7d485b
temporal: Fix unused-import (F401) in testsuite
echoix Oct 7, 2024
7a15c41
grass.temporal: Fix unused-import (F401)
echoix Oct 7, 2024
089d5f2
grass.benchmark: Fix unused-import (F401) by defining __all__
echoix Oct 7, 2024
84510ac
grass.pygrass.vector: Fix unused-import (F401) for testsuite
echoix Oct 7, 2024
75f6c14
grass.pygrass.vector: Sort imports
echoix Oct 7, 2024
c333b84
vector: Fix unused-import (F401) for testsuite
echoix Oct 7, 2024
eac4d5a
scripts: Fix unused-import (F401) for testsuite
echoix Oct 7, 2024
742e2ee
raster: Fix unused-import (F401) for testsuite
echoix Oct 7, 2024
c7371e3
v.fill.holes: Fix unused-import (F401)
echoix Oct 7, 2024
6d6a5e0
doc: Fix unused-import (F401)
echoix Oct 7, 2024
147d5a1
grass.semantic_label: Fix unused-import (F401) by defining __all__ in…
echoix Oct 7, 2024
562bdca
grass.pygrass.rpc: Fix unused-import (F401) in __init__
echoix Oct 7, 2024
b05d27c
grass.pygrass.modules.interface: Fix unused-import (F401) by defining…
echoix Oct 7, 2024
28b7194
grass.pygrass.modules.interface: Apply isort
echoix Oct 7, 2024
64567c2
grass.pygrass.modules.grid: Fix unused-import (F401) by defining __al…
echoix Oct 7, 2024
cdc4380
grass.pygrass.modules: Fix unused-import (F401) by defining __all__ i…
echoix Oct 7, 2024
6a6aa63
grass.pygrass.modules: Apply isort
echoix Oct 7, 2024
1c13ab0
grass.imaging: Fix unused-import (F401) by defining __all__ in __init__
echoix Oct 7, 2024
d2becc9
grass.imaging: Apply isort
echoix Oct 7, 2024
cd8f4dc
grass.jupyter: Fix unused-import (F401) by defining __all__ in __init__
echoix Oct 7, 2024
c83476d
grass.jupyter: Apply isort
echoix Oct 7, 2024
2a62682
pygrass: Ignore F401 (unused imports)
echoix Oct 14, 2024
b8fd615
lib/gis: Fix F401 unused platform import in test_gis_lib_getl
echoix Oct 14, 2024
06a9dd5
grass.script: Ignore F401 in `__init__.py` for setup import
echoix Oct 14, 2024
422f1bb
style: Remove exclusion for F401 ruff rule
echoix Oct 14, 2024
4ccafbf
style: Remove unneeded flake8 exclusions for F401
echoix Oct 14, 2024
84dc11d
Merge branch 'main' into tests-unused-imports
echoix Oct 18, 2024
fafd964
Apply suggestions from code review
echoix Oct 23, 2024
4a719e3
Merge branch 'main' into tests-unused-imports
echoix Oct 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ per-file-ignores =
# E501 line too long
# E722 do not use bare 'except'
# W605 invalid escape sequence
# F401 imported but unused
# F821 undefined name 'unicode'
# F841 local variable assigned to but never used
# E741 ambiguous variable name 'l'
__init__.py: F401, F403
__init__.py: F403
man/build_html.py: E501
doc/python/m.distance.py: E501
gui/scripts/d.wms.py: E501
Expand Down Expand Up @@ -66,10 +65,8 @@ per-file-ignores =
python/grass/pygrass/vector/__init__.py: E402
python/grass/pygrass/raster/__init__.py: E402
python/grass/pygrass/vector/__init__.py: E402
python/grass/pygrass/modules/interface/*.py: F401
python/grass/pygrass/modules/grid/*.py: F401
python/grass/pygrass/raster/category.py: E721
python/grass/pygrass/rpc/__init__.py: F401, F403
python/grass/pygrass/rpc/__init__.py: F403
python/grass/pygrass/utils.py: E402
python/grass/temporal/abstract_space_time_dataset.py: E722
python/grass/temporal/c_libraries_interface.py: E722
Expand All @@ -82,17 +79,16 @@ per-file-ignores =
python/grass/temporal/temporal_topology_dataset_connector.py: E722
# Current benchmarks/tests are changing sys.path before import.
# Possibly, a different approach should be taken there anyway.
python/grass/pygrass/tests/benchmark.py: E402, F401, F821
python/grass/pygrass/tests/benchmark.py: E402, F821
# Configuration file for Sphinx:
# Ignoring import/code mix and line length.
# Files not managed by Black
python/grass/imaging/images2gif.py: E226
# Unused imports in init files
# F401 imported but unused
# F403 star import used; unable to detect undefined names
python/grass/*/__init__.py: F401, F403
python/grass/*/*/__init__.py: F401, F403
python/grass/*/*/*/__init__.py: F401, F403
python/grass/*/*/__init__.py: F403
python/grass/*/*/*/__init__.py: F403
# E402 module level import not at top of file
scripts/r.in.wms/wms_gdal_drv.py: E722
scripts/r.in.wms/wms_drv.py: E402, E722
Expand Down
1 change: 0 additions & 1 deletion doc/notebooks/hydrology.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"outputs": [],
"source": [
"# Import Python standard library and IPython packages we need.\n",
"import os\n",
"import subprocess\n",
"import sys\n",
"import csv\n",
Expand Down
1 change: 0 additions & 1 deletion doc/notebooks/jupyter_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"source": [
"# Import Python standard library and IPython packages we need.\n",
"import subprocess\n",
"import time\n",
"import sys\n",
"\n",
"# Ask GRASS GIS where its Python packages are.\n",
Expand Down
1 change: 0 additions & 1 deletion doc/notebooks/parallelization_tutorial.ipynb
petrasovaa marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import subprocess\n",
"import sys\n",
"\n",
Expand Down
1 change: 0 additions & 1 deletion doc/notebooks/solar_potential.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"outputs": [],
"source": [
"# Import Python standard library and IPython packages we need.\n",
"import os\n",
"import subprocess\n",
"import sys\n",
"\n",
Expand Down
1 change: 0 additions & 1 deletion doc/notebooks/viewshed_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"outputs": [],
"source": [
"# Import Python standard library and IPython packages we need.\n",
"import os\n",
"import subprocess\n",
"import sys\n",
"\n",
Expand Down
1 change: 0 additions & 1 deletion lib/gis/testsuite/test_gis_lib_getl.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import ctypes
import pathlib
import platform
import unittest

import grass.lib.gis as libgis
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ ignore = [
"E722", # bare-except
"E731", # lambda-assignment
"E741", # ambiguous-variable-name
"F401", # unused-import
"F403", # undefined-local-with-import-star
"F405", # undefined-local-with-import-star-usage
"F811", # redefined-while-unused
Expand Down Expand Up @@ -319,7 +318,9 @@ ignore = [
"python/grass/jupyter/testsuite/map_test.py" = ["PGH004"]
"python/grass/pydispatch/signal.py" = ["A005"]
"python/grass/pygrass/modules/grid/grid.py" = ["SIM115"]
"python/grass/pygrass/modules/grid/testsuite/test_*_modules_grid_doctests.py" = ["F401"]
petrasovaa marked this conversation as resolved.
Show resolved Hide resolved
"python/grass/pygrass/modules/interface/env.py" = ["SIM115"]
"python/grass/pygrass/modules/testsuite/test_pygrass_modules_doctests.py" = ["F401"]
"python/grass/pygrass/raster/segment.py" = ["SIM115"]
"python/grass/pygrass/tests/*.py" = ["SIM115"]
"python/grass/pygrass/vector/geometry.py" = ["PYI024"]
Expand Down
14 changes: 14 additions & 0 deletions python/grass/benchmark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,17 @@
save_results_to_file,
)
from .runners import benchmark_nprocs, benchmark_resolutions, benchmark_single

__all__ = [
"benchmark_nprocs",
"benchmark_resolutions",
"benchmark_single",
"join_results",
"join_results_from_files",
"load_results",
"load_results_from_file",
"nprocs_plot",
"num_cells_plot",
"save_results",
"save_results_to_file",
]
15 changes: 13 additions & 2 deletions python/grass/imaging/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
from grass.imaging.images2gif import readGif, writeGif
from grass.imaging.images2swf import readSwf, writeSwf
from grass.imaging.images2avi import readAvi, writeAvi
from grass.imaging.images2gif import readGif, writeGif
from grass.imaging.images2ims import readIms, writeIms
from grass.imaging.images2swf import readSwf, writeSwf

__all__ = [
"readAvi",
"readGif",
"readIms",
"readSwf",
"writeAvi",
"writeGif",
"writeIms",
"writeSwf",
]
13 changes: 12 additions & 1 deletion python/grass/jupyter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@
from .interactivemap import InteractiveMap, Raster, Vector
from .map import Map
from .map3d import Map3D
from .seriesmap import SeriesMap
from .setup import init
from .timeseriesmap import TimeSeriesMap
from .seriesmap import SeriesMap

__all__ = [
"InteractiveMap",
"Map",
"Map3D",
"Raster",
"SeriesMap",
"TimeSeriesMap",
"Vector",
"init",
]
9 changes: 8 additions & 1 deletion python/grass/pygrass/modules/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
from grass.pygrass.modules.interface import Module, MultiModule, ParallelModuleQueue
from grass.pygrass.modules import shortcuts
from grass.pygrass.modules.interface import Module, MultiModule, ParallelModuleQueue

__all__ = [
"Module",
"MultiModule",
"ParallelModuleQueue",
"shortcuts",
]
2 changes: 2 additions & 0 deletions python/grass/pygrass/modules/grid/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from grass.pygrass.modules.grid.grid import GridModule

__all__ = ["GridModule"]
18 changes: 12 additions & 6 deletions python/grass/pygrass/modules/interface/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@
@author: pietro
"""

from grass.pygrass.modules.interface import flag
from grass.pygrass.modules.interface import parameter
from grass.pygrass.modules.interface import module
from grass.pygrass.modules.interface import typedict
from grass.pygrass.modules.interface import read

from grass.pygrass.modules.interface import flag, module, parameter, read, typedict
from grass.pygrass.modules.interface.module import (
Module,
MultiModule,
ParallelModuleQueue,
)

__all__ = [
"Module",
"MultiModule",
"ParallelModuleQueue",
"flag",
"module",
"parameter",
"read",
"typedict",
]
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,17 @@ def test_import_isolation(self):
isolate, check(*self.patterns), msg="Test isolation before any import."
)
# same import done in __init__ file
from grass.pygrass.modules.interface import Module, ParallelModuleQueue
from grass.pygrass.modules import shortcuts
from grass.pygrass.modules.interface import (
Module, # noqa: F401
ParallelModuleQueue, # noqa: F401
)
from grass.pygrass.modules import shortcuts # noqa: F401

self.assertEqual(
isolate, check(*self.patterns), msg="Test isolation after import Module."
)
# test the other way round
from grass.pygrass.vector import VectorTopo
from grass.pygrass.vector import VectorTopo # noqa: F401

self.assertNotEqual(
isolate,
Expand Down
3 changes: 0 additions & 3 deletions python/grass/pygrass/rpc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
:authors: Soeren Gebbert
"""

import time
import threading
import sys
from multiprocessing import Process, Lock, Pipe
from ctypes import CFUNCTYPE, c_void_p
Expand All @@ -24,7 +22,6 @@
from .base import RPCServerBase
from grass.pygrass.gis.region import Region
from grass.pygrass import utils
import logging

###############################################################################
###############################################################################
Expand Down
1 change: 0 additions & 1 deletion python/grass/pygrass/vector/testsuite/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from grass.gunittest.case import TestCase
from grass.gunittest.main import test

from grass.pygrass.vector.table import Filters


Expand Down
11 changes: 4 additions & 7 deletions python/grass/pygrass/vector/testsuite/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,15 @@

import sys
import unittest

import numpy as np

import grass.lib.vector as libvect
from grass.gunittest.case import TestCase
from grass.gunittest.main import test

import grass.lib.vector as libvect
from grass.script.core import run_command

from grass.pygrass.vector import Vector, VectorTopo
from grass.pygrass.vector.geometry import Point, Line, Node
from grass.pygrass.vector.geometry import Area, Boundary, Centroid
from grass.pygrass.vector import VectorTopo
from grass.pygrass.vector.basic import Bbox
from grass.pygrass.vector.geometry import Area, Line, Node, Point


class PointTestCase(TestCase):
Expand Down
8 changes: 0 additions & 8 deletions python/grass/pygrass/vector/testsuite/test_geometry_attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,8 @@
@author: pietro
"""

import sys
import unittest
import numpy as np

from grass.gunittest.case import TestCase
from grass.gunittest.main import test

import grass.lib.vector as libvect
from grass.script.core import run_command

from grass.pygrass.vector import VectorTopo


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
import grass.gunittest.case
import grass.gunittest.main
import grass.gunittest.utils

import grass.pygrass.vector as gvector
import grass.pygrass.utils as gutils


# doctest does not allow changing the base classes of test case, skip test case
# and test suite, so we need to create a new type which inherits from our class
Expand Down
5 changes: 2 additions & 3 deletions python/grass/pygrass/vector/testsuite/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
import os
import sqlite3
import tempfile as tmp
from string import ascii_letters, digits
from random import choice
from string import ascii_letters, digits

import numpy as np

from grass.gunittest.case import TestCase
from grass.gunittest.main import test

from grass.pygrass.vector.table import Table, get_path


# dictionary that generate random data
RNG = np.random.default_rng()
COL2VALS = {
Expand Down
2 changes: 0 additions & 2 deletions python/grass/pygrass/vector/testsuite/test_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

from grass.gunittest.case import TestCase
from grass.gunittest.main import test

from grass.script.core import run_command
from grass.pygrass.vector import VectorTopo


Expand Down
6 changes: 1 addition & 5 deletions python/grass/pygrass/vector/testsuite/test_vector3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@

from grass.gunittest.case import TestCase
from grass.gunittest.main import test

from grass.script.core import run_command

from grass.pygrass.gis.region import Region
from grass.pygrass.vector import VectorTopo
from grass.pygrass.vector.geometry import Point
from grass.pygrass.gis.region import Region
from grass.pygrass.utils import get_mapset_vector


def generate_coordinates(number, bbox=None, with_z=False):
Expand Down
2 changes: 1 addition & 1 deletion python/grass/script/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
from .raster3d import *
from .vector import *
from .utils import *
from . import setup
from . import setup # noqa: F401
2 changes: 2 additions & 0 deletions python/grass/semantic_label/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .reader import SemanticLabelReader, SemanticLabelReaderError

__all__ = ["SemanticLabelReader", "SemanticLabelReaderError"]
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"""

import datetime
import os

import grass.temporal as tgis
from grass.gunittest.case import TestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"""

import datetime
import os

import grass.temporal as tgis
from grass.gunittest.case import TestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"""

import datetime
import os

import grass.temporal as tgis
from grass.gunittest.case import TestCase
Expand Down
1 change: 0 additions & 1 deletion raster/r.in.ascii/testsuite/test_r_in_ascii.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

from grass.gunittest.case import TestCase
from grass.gunittest.main import test
from grass.script.core import read_command

INPUT_NOQUOTES = """north: 4299000.00
south: 4247000.00
Expand Down
Loading
Loading