add comments to suppress useless warnings from LGTM

This commit is contained in:
Axel Kohlmeyer
2021-05-15 23:35:14 -04:00
parent 185664824e
commit fde2295685
5 changed files with 20 additions and 20 deletions

View File

@ -123,7 +123,7 @@ try:
sys.argv = ["setup.py","install"] # as if had run "python setup.py install" 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_kwargs['data_files']=[(os.path.join(get_python_lib(), 'lammps'), [args.lib])]
setup(**setup_kwargs) setup(**setup_kwargs)
except: except: # lgtm [py/catch-base-exception]
tryuser=True tryuser=True
print ("Installation into global site-packages folder failed.\nTrying user folder %s now." % site.USER_SITE) 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" 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_kwargs['data_files']=[(os.path.join(site.USER_SITE, 'lammps'), [args.lib])]
setup(**setup_kwargs) setup(**setup_kwargs)
except: except: # lgtm [py/catch-base-exception]
print("Installation into user site package folder failed.") print("Installation into user site package folder failed.")

View File

@ -8,10 +8,10 @@ LAMMPS module global members:
result of :py:func:`lammps.version`. result of :py:func:`lammps.version`.
""" """
from .constants import * from .constants import * # lgtm [py/polluting-import]
from .core import * from .core import * # lgtm [py/polluting-import]
from .data import * from .data import * # lgtm [py/polluting-import]
from .pylammps import * from .pylammps import * # lgtm [py/polluting-import]
# convert installed module string version to numeric version # convert installed module string version to numeric version
def get_version_number(): def get_version_number():
@ -28,7 +28,7 @@ def get_version_number():
from importlib.metadata import version from importlib.metadata import version
try: try:
vstring = version('lammps') vstring = version('lammps')
except: except: # lgtm [py/catch-base-exception]
# nothing to do, ignore # nothing to do, ignore
pass pass
@ -36,7 +36,7 @@ def get_version_number():
from pkg_resources import get_distribution from pkg_resources import get_distribution
try: try:
vstring = get_distribution('lammps').version vstring = get_distribution('lammps').version
except: except: # lgtm [py/catch-base-exception]
# nothing to do, ignore # nothing to do, ignore
pass pass

View File

@ -18,12 +18,12 @@ from __future__ import print_function
import os import os
import sys import sys
from ctypes import * from ctypes import * # lgtm [py/polluting-import]
from os.path import dirname,abspath,join from os.path import dirname,abspath,join
from inspect import getsourcefile from inspect import getsourcefile
from .constants import * from .constants import * # lgtm [py/polluting-import]
from .data import * from .data import * # lgtm [py/polluting-import]
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
@ -100,7 +100,7 @@ class lammps(object):
try: try:
if ptr: self.lib = CDLL("",RTLD_GLOBAL) if ptr: self.lib = CDLL("",RTLD_GLOBAL)
except: except: # lgtm [py/catch-base-exception]
self.lib = None self.lib = None
# load liblammps.so unless name is given # load liblammps.so unless name is given
@ -307,7 +307,7 @@ class lammps(object):
from mpi4py import __version__ as mpi4py_version from mpi4py import __version__ as mpi4py_version
# tested to work with mpi4py versions 2 and 3 # tested to work with mpi4py versions 2 and 3
self.has_mpi4py = mpi4py_version.split('.')[0] in ['2','3'] self.has_mpi4py = mpi4py_version.split('.')[0] in ['2','3']
except: except: # lgtm [py/catch-base-exception]
# ignore failing import # ignore failing import
pass pass
@ -1352,7 +1352,7 @@ class lammps(object):
id_lmp = (self.c_tagint*n)() id_lmp = (self.c_tagint*n)()
try: try:
id_lmp[:] = id[0:n] id_lmp[:] = id[0:n]
except: except: # lgtm [py/catch-base-exception]
return 0 return 0
else: else:
id_lmp = None id_lmp = None
@ -1360,21 +1360,21 @@ class lammps(object):
type_lmp = (c_int*n)() type_lmp = (c_int*n)()
try: try:
type_lmp[:] = type[0:n] type_lmp[:] = type[0:n]
except: except: # lgtm [py/catch-base-exception]
return 0 return 0
three_n = 3*n three_n = 3*n
x_lmp = (c_double*three_n)() x_lmp = (c_double*three_n)()
try: try:
x_lmp[:] = x[0:three_n] x_lmp[:] = x[0:three_n]
except: except: # lgtm [py/catch-base-exception]
return 0 return 0
if v: if v:
v_lmp = (c_double*(three_n))() v_lmp = (c_double*(three_n))()
try: try:
v_lmp[:] = v[0:three_n] v_lmp[:] = v[0:three_n]
except: except: # lgtm [py/catch-base-exception]
return 0 return 0
else: else:
v_lmp = None v_lmp = None
@ -1383,7 +1383,7 @@ class lammps(object):
img_lmp = (self.c_imageint*n)() img_lmp = (self.c_imageint*n)()
try: try:
img_lmp[:] = image[0:n] img_lmp[:] = image[0:n]
except: except: # lgtm [py/catch-base-exception]
return 0 return 0
else: else:
img_lmp = None img_lmp = None

View File

@ -20,7 +20,7 @@ import warnings
from ctypes import POINTER, c_double, c_int, c_int32, c_int64, cast 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 from .data import NeighList

View File

@ -31,7 +31,7 @@ if not tests_dir:
try: try:
src_dir = os.path.abspath(os.path.expanduser(src_dir)) src_dir = os.path.abspath(os.path.expanduser(src_dir))
tests_dir = os.path.abspath(os.path.expanduser(tests_dir)) tests_dir = os.path.abspath(os.path.expanduser(tests_dir))
except: except: # lgtm [py/catch-base-exception]
parser.print_help() parser.print_help()
sys.exit(1) sys.exit(1)