From 92ab37e7e59eb6420abdeab8eec659016706a81b Mon Sep 17 00:00:00 2001 From: Alexandre Barreto Date: Tue, 31 Jan 2023 13:23:11 -0500 Subject: [PATCH] pythonlib: Remove star imports (#1546) Replaces star import (from x import *) by regular imports (from x import y). Enables the relevant Flake8 warnings. Adds the warning to per-file ignores for init files where we expect and allow using star imports (unfortunately some init files contain actual code suffers from these warning being disabled, but that's a different issue). --- python/grass/.flake8 | 10 ++++++++++ python/grass/gunittest/invoker.py | 19 +++++++++++++++++++ .../grass/temporal/c_libraries_interface.py | 17 +++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/python/grass/.flake8 b/python/grass/.flake8 index 303d7f67b68..df39068361b 100644 --- a/python/grass/.flake8 +++ b/python/grass/.flake8 @@ -34,6 +34,7 @@ ignore = <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= >>>>>>> main ======= @@ -107,6 +108,8 @@ ignore = >>>>>>> osgeo-main ======= >>>>>>> 9fb6588182 (g.proj: fix reading input WKT (#1582)) +======= +>>>>>>> c5d3b09cb4 (pythonlib: Remove star imports (#1546)) ======= E722, # do not use bare 'except' >>>>>>> 7e8f036e2d (pythonlib: Remove star imports (#1546)) @@ -129,6 +132,7 @@ ignore = <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= >>>>>>> 95f198e1e0 (g.proj: fix reading input WKT (#1582)) ======= @@ -177,6 +181,9 @@ ignore = ======= ======= >>>>>>> osgeo-main +======= +======= +>>>>>>> c5d3b09cb4 (pythonlib: Remove star imports (#1546)) ======= E722, # do not use bare 'except' >>>>>>> 7e8f036e2d (pythonlib: Remove star imports (#1546)) @@ -192,6 +199,7 @@ ignore = <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= >>>>>>> 7e7871fd90 (g.proj: fix reading input WKT (#1582)) <<<<<<< HEAD @@ -297,6 +305,8 @@ ignore = >>>>>>> 3ced907ea6 (pythonlib: Remove star imports (#1546)) ======= >>>>>>> 9fb6588182 (g.proj: fix reading input WKT (#1582)) +======= +>>>>>>> c5d3b09cb4 (pythonlib: Remove star imports (#1546)) per-file-ignores = # C wrappers call libgis.G_gisinit before importing other modules. diff --git a/python/grass/gunittest/invoker.py b/python/grass/gunittest/invoker.py index 40bcd512261..cc3b186fdee 100644 --- a/python/grass/gunittest/invoker.py +++ b/python/grass/gunittest/invoker.py @@ -335,6 +335,7 @@ def _run_test_module(self, module, results_dir, gisdbase, location, timeout): <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= >>>>>>> main ======= @@ -377,6 +378,8 @@ def _run_test_module(self, module, results_dir, gisdbase, location, timeout): ======= >>>>>>> b5acd78515 (wxpyimgview: explicit conversion to int (#2704)) ======= +>>>>>>> c5d3b09cb4 (pythonlib: Remove star imports (#1546)) +======= >>>>>>> 6cf60c76a4 (wxpyimgview: explicit conversion to int (#2704)) ======= >>>>>>> 8422103f4c (wxpyimgview: explicit conversion to int (#2704)) @@ -392,6 +395,7 @@ def _run_test_module(self, module, results_dir, gisdbase, location, timeout): <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= >>>>>>> 57aff3a06a (pythonlib: Remove star imports (#1546)) <<<<<<< HEAD @@ -475,6 +479,10 @@ def _run_test_module(self, module, results_dir, gisdbase, location, timeout): >>>>>>> bc7152a288 (wxpyimgview: explicit conversion to int (#2704)) ======= >>>>>>> b5acd78515 (wxpyimgview: explicit conversion to int (#2704)) +======= +======= +>>>>>>> 57aff3a06a (pythonlib: Remove star imports (#1546)) +>>>>>>> c5d3b09cb4 (pythonlib: Remove star imports (#1546)) stdout = p.stdout stderr = p.stderr returncode = p.returncode @@ -865,6 +873,7 @@ def _run_test_module(self, module, results_dir, gisdbase, location, timeout): ======= stdout, stderr = p.communicate() returncode = p.returncode +<<<<<<< HEAD ======= >>>>>>> 6cf60c76a4 (wxpyimgview: explicit conversion to int (#2704)) encodings = [_get_encoding(), "utf8", "latin-1", "ascii"] @@ -875,6 +884,10 @@ def _run_test_module(self, module, results_dir, gisdbase, location, timeout): >>>>>>> f4b9197871 (pythonlib: Remove star imports (#1546)) ======= ======= +======= + encodings = [_get_encoding(), "utf8", "latin-1", "ascii"] + +>>>>>>> 57aff3a06a (pythonlib: Remove star imports (#1546)) >>>>>>> 7e8f036e2d (pythonlib: Remove star imports (#1546)) >>>>>>> 3ced907ea6 (pythonlib: Remove star imports (#1546)) def try_decode(data, encodings): @@ -913,6 +926,7 @@ def try_decode(data, encodings): <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= >>>>>>> main ======= @@ -937,6 +951,8 @@ def try_decode(data, encodings): >>>>>>> f4219c860c (libpython: Save and load benchmark results (#1711)) ======= >>>>>>> b5acd78515 (wxpyimgview: explicit conversion to int (#2704)) +======= +>>>>>>> c5d3b09cb4 (pythonlib: Remove star imports (#1546)) return decode(data, encoding=encoding) ======= <<<<<<< HEAD @@ -1047,6 +1063,7 @@ def try_decode(data, encodings): <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= <<<<<<< HEAD >>>>>>> main @@ -1161,6 +1178,8 @@ def try_decode(data, encodings): return decode(data, encoding=encoding) >>>>>>> 8422103f4c (wxpyimgview: explicit conversion to int (#2704)) >>>>>>> b5acd78515 (wxpyimgview: explicit conversion to int (#2704)) +======= +>>>>>>> c5d3b09cb4 (pythonlib: Remove star imports (#1546)) except UnicodeError: pass if isinstance(data, bytes): diff --git a/python/grass/temporal/c_libraries_interface.py b/python/grass/temporal/c_libraries_interface.py index b48095c7562..b3ae3050135 100644 --- a/python/grass/temporal/c_libraries_interface.py +++ b/python/grass/temporal/c_libraries_interface.py @@ -41,6 +41,7 @@ <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= >>>>>>> main ======= @@ -421,6 +422,8 @@ >>>>>>> f4219c860c (libpython: Save and load benchmark results (#1711)) ======= >>>>>>> b5acd78515 (wxpyimgview: explicit conversion to int (#2704)) +======= +>>>>>>> c5d3b09cb4 (pythonlib: Remove star imports (#1546)) import sys from ctypes import CFUNCTYPE, POINTER, byref, c_int, c_void_p, cast ======= @@ -430,6 +433,8 @@ >>>>>>> 2bf163e4b3 (libpython: Save and load benchmark results (#1711)) ======= >>>>>>> dad8f82179 (wxpyimgview: explicit conversion to int (#2704)) +======= +>>>>>>> 95adae2f53 (pythonlib: Remove star imports (#1546)) <<<<<<< HEAD from ctypes import byref, cast, c_int, c_void_p, CFUNCTYPE, POINTER ======= @@ -462,8 +467,20 @@ ======= from ctypes import byref, cast, c_int, c_void_p, CFUNCTYPE, POINTER >>>>>>> 8422103f4c (wxpyimgview: explicit conversion to int (#2704)) +<<<<<<< HEAD >>>>>>> dad8f82179 (wxpyimgview: explicit conversion to int (#2704)) +<<<<<<< HEAD >>>>>>> b5acd78515 (wxpyimgview: explicit conversion to int (#2704)) +======= +======= +======= +from ctypes import byref, cast, c_int, c_void_p, CFUNCTYPE, POINTER +======= +from ctypes import byref, cast, c_char_p, c_int, c_void_p, CFUNCTYPE, POINTER +>>>>>>> 7e8f036e2d (pythonlib: Remove star imports (#1546)) +>>>>>>> 57aff3a06a (pythonlib: Remove star imports (#1546)) +>>>>>>> 95adae2f53 (pythonlib: Remove star imports (#1546)) +>>>>>>> c5d3b09cb4 (pythonlib: Remove star imports (#1546)) from datetime import datetime from multiprocessing import Lock, Pipe, Process