From fde2295685dc613bdc06fc055f962bd0befaaa9e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 15 May 2021 23:35:14 -0400 Subject: [PATCH] add comments to suppress useless warnings from LGTM --- python/install.py | 4 ++-- python/lammps/__init__.py | 12 ++++++------ python/lammps/core.py | 20 ++++++++++---------- python/lammps/numpy_wrapper.py | 2 +- unittest/force-styles/check_tests.py | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/python/install.py b/python/install.py index 10bd4f6de1..a3668754d9 100644 --- a/python/install.py +++ b/python/install.py @@ -123,7 +123,7 @@ try: sys.argv = ["setup.py","install"] # as if had run "python setup.py install" setup_kwargs['data_files']=[(os.path.join(get_python_lib(), 'lammps'), [args.lib])] setup(**setup_kwargs) -except: +except: # lgtm [py/catch-base-exception] tryuser=True print ("Installation into global site-packages folder failed.\nTrying user folder %s now." % site.USER_SITE) @@ -132,5 +132,5 @@ if tryuser: sys.argv = ["setup.py","install","--user"] # as if had run "python setup.py install --user" setup_kwargs['data_files']=[(os.path.join(site.USER_SITE, 'lammps'), [args.lib])] setup(**setup_kwargs) - except: + except: # lgtm [py/catch-base-exception] print("Installation into user site package folder failed.") diff --git a/python/lammps/__init__.py b/python/lammps/__init__.py index a51e0db207..9381d6b80c 100644 --- a/python/lammps/__init__.py +++ b/python/lammps/__init__.py @@ -8,10 +8,10 @@ LAMMPS module global members: result of :py:func:`lammps.version`. """ -from .constants import * -from .core import * -from .data import * -from .pylammps import * +from .constants import * # lgtm [py/polluting-import] +from .core import * # lgtm [py/polluting-import] +from .data import * # lgtm [py/polluting-import] +from .pylammps import * # lgtm [py/polluting-import] # convert installed module string version to numeric version def get_version_number(): @@ -28,7 +28,7 @@ def get_version_number(): from importlib.metadata import version try: vstring = version('lammps') - except: + except: # lgtm [py/catch-base-exception] # nothing to do, ignore pass @@ -36,7 +36,7 @@ def get_version_number(): from pkg_resources import get_distribution try: vstring = get_distribution('lammps').version - except: + except: # lgtm [py/catch-base-exception] # nothing to do, ignore pass diff --git a/python/lammps/core.py b/python/lammps/core.py index 800a1eab29..e31c6505e3 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -18,12 +18,12 @@ from __future__ import print_function import os import sys -from ctypes import * +from ctypes import * # lgtm [py/polluting-import] from os.path import dirname,abspath,join from inspect import getsourcefile -from .constants import * -from .data import * +from .constants import * # lgtm [py/polluting-import] +from .data import * # lgtm [py/polluting-import] # ------------------------------------------------------------------------- @@ -100,7 +100,7 @@ class lammps(object): try: if ptr: self.lib = CDLL("",RTLD_GLOBAL) - except: + except: # lgtm [py/catch-base-exception] self.lib = None # load liblammps.so unless name is given @@ -307,7 +307,7 @@ class lammps(object): from mpi4py import __version__ as mpi4py_version # tested to work with mpi4py versions 2 and 3 self.has_mpi4py = mpi4py_version.split('.')[0] in ['2','3'] - except: + except: # lgtm [py/catch-base-exception] # ignore failing import pass @@ -1352,7 +1352,7 @@ class lammps(object): id_lmp = (self.c_tagint*n)() try: id_lmp[:] = id[0:n] - except: + except: # lgtm [py/catch-base-exception] return 0 else: id_lmp = None @@ -1360,21 +1360,21 @@ class lammps(object): type_lmp = (c_int*n)() try: type_lmp[:] = type[0:n] - except: + except: # lgtm [py/catch-base-exception] return 0 three_n = 3*n x_lmp = (c_double*three_n)() try: x_lmp[:] = x[0:three_n] - except: + except: # lgtm [py/catch-base-exception] return 0 if v: v_lmp = (c_double*(three_n))() try: v_lmp[:] = v[0:three_n] - except: + except: # lgtm [py/catch-base-exception] return 0 else: v_lmp = None @@ -1383,7 +1383,7 @@ class lammps(object): img_lmp = (self.c_imageint*n)() try: img_lmp[:] = image[0:n] - except: + except: # lgtm [py/catch-base-exception] return 0 else: img_lmp = None diff --git a/python/lammps/numpy_wrapper.py b/python/lammps/numpy_wrapper.py index 399affa51a..20fdf4cc68 100644 --- a/python/lammps/numpy_wrapper.py +++ b/python/lammps/numpy_wrapper.py @@ -20,7 +20,7 @@ import warnings from ctypes import POINTER, c_double, c_int, c_int32, c_int64, cast -from .constants import * +from .constants import * # lgtm [py/polluting-import] from .data import NeighList diff --git a/unittest/force-styles/check_tests.py b/unittest/force-styles/check_tests.py index a0934eabe8..cca1b9f84d 100755 --- a/unittest/force-styles/check_tests.py +++ b/unittest/force-styles/check_tests.py @@ -31,7 +31,7 @@ if not tests_dir: try: src_dir = os.path.abspath(os.path.expanduser(src_dir)) tests_dir = os.path.abspath(os.path.expanduser(tests_dir)) -except: +except: # lgtm [py/catch-base-exception] parser.print_help() sys.exit(1)