From 341a4bbaec8d15a45b4e68b9df6937556e4bbe00 Mon Sep 17 00:00:00 2001 From: Don Cross Date: Tue, 7 Feb 2023 14:27:06 -0500 Subject: [PATCH] Fixed overly general exception in Python code. Pylint discovered that I was raising Exception, which was overly general. I didn't mean to do that; it was supposed to be my custom exception type astronomy.Error instead. So I fixed that case. There were also some deprecated settings in the pylint configuration file, so I fixed those too. --- demo/python/astronomy.py | 2 +- generate/pylintrc | 7 ++----- generate/template/astronomy.py | 2 +- source/python/astronomy/astronomy.py | 2 +- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/demo/python/astronomy.py b/demo/python/astronomy.py index ed680399..c96025bc 100644 --- a/demo/python/astronomy.py +++ b/demo/python/astronomy.py @@ -6955,7 +6955,7 @@ def SphereFromVector(vector): dist = math.sqrt(xyproj + vector.z*vector.z) if xyproj == 0.0: if vector.z == 0.0: - raise Exception('Zero-length vector not allowed.') + raise Error('Zero-length vector not allowed.') lon = 0.0 if vector.z < 0.0: lat = -90.0 diff --git a/generate/pylintrc b/generate/pylintrc index 8c3bf748..bab503c9 100644 --- a/generate/pylintrc +++ b/generate/pylintrc @@ -103,9 +103,7 @@ disable=invalid-name, chained-comparison, consider-using-in, too-many-nested-blocks, - too-many-instance-attributes, - bad-whitespace, - bad-continuation + too-many-instance-attributes # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option @@ -576,5 +574,4 @@ preferred-modules= # Exceptions that will emit a warning when being caught. Defaults to # "BaseException, Exception". -overgeneral-exceptions=BaseException, - Exception +overgeneral-exceptions=builtins.BaseException, builtins.Exception diff --git a/generate/template/astronomy.py b/generate/template/astronomy.py index cabe963c..bdedfa60 100644 --- a/generate/template/astronomy.py +++ b/generate/template/astronomy.py @@ -5449,7 +5449,7 @@ def SphereFromVector(vector): dist = math.sqrt(xyproj + vector.z*vector.z) if xyproj == 0.0: if vector.z == 0.0: - raise Exception('Zero-length vector not allowed.') + raise Error('Zero-length vector not allowed.') lon = 0.0 if vector.z < 0.0: lat = -90.0 diff --git a/source/python/astronomy/astronomy.py b/source/python/astronomy/astronomy.py index ed680399..c96025bc 100644 --- a/source/python/astronomy/astronomy.py +++ b/source/python/astronomy/astronomy.py @@ -6955,7 +6955,7 @@ def SphereFromVector(vector): dist = math.sqrt(xyproj + vector.z*vector.z) if xyproj == 0.0: if vector.z == 0.0: - raise Exception('Zero-length vector not allowed.') + raise Error('Zero-length vector not allowed.') lon = 0.0 if vector.z < 0.0: lat = -90.0