From 67bf48158d37059b7e5613e37e7a6d8b064ff6ae Mon Sep 17 00:00:00 2001 From: Rick Gutleber Date: Sat, 30 Dec 2023 12:21:24 -0500 Subject: [PATCH] some pylint fixes --- pylintrc | 82 +------------------------------- rpn/makeHelp.py | 6 +-- rpn/math/rpnNumberTheory.py | 4 +- rpn/math/rpnPolytope.py | 2 +- rpn/rpnOperators.py | 2 +- rpn/science/rpnPhysics.py | 2 +- rpn/special/rpnLocation.py | 5 +- rpn/special/rpnLocationLookup.py | 3 ++ rpn/util/rpnOutput.py | 2 +- 9 files changed, 15 insertions(+), 93 deletions(-) diff --git a/pylintrc b/pylintrc index 5ff5ef7..8256d6a 100644 --- a/pylintrc +++ b/pylintrc @@ -60,16 +60,7 @@ confidence= # --enable=similarities". If you want to run only the classes checker, but have # no Warning level messages displayed, use "--disable=all --enable=classes # --disable=W". -disable=print-statement, - parameter-unpacking, - unpacking-in-except, - old-raise-syntax, - backtick, - long-suffix, - old-ne-operator, - old-octal-literal, - import-star-module-level, - non-ascii-bytes-literal, +disable=parameter-unpacking, raw-checker-failed, bad-inline-option, locally-disabled, @@ -78,68 +69,6 @@ disable=print-statement, useless-suppression, deprecated-pragma, use-symbolic-message-instead, - apply-builtin, - basestring-builtin, - buffer-builtin, - cmp-builtin, - coerce-builtin, - execfile-builtin, - file-builtin, - long-builtin, - raw_input-builtin, - reduce-builtin, - standarderror-builtin, - unicode-builtin, - xrange-builtin, - coerce-method, - delslice-method, - getslice-method, - setslice-method, - no-absolute-import, - old-division, - dict-iter-method, - dict-view-method, - next-method-called, - metaclass-assignment, - indexing-exception, - raising-string, - reload-builtin, - oct-method, - hex-method, - nonzero-method, - cmp-method, - input-builtin, - round-builtin, - intern-builtin, - unichr-builtin, - map-builtin-not-iterating, - zip-builtin-not-iterating, - range-builtin-not-iterating, - filter-builtin-not-iterating, - using-cmp-argument, - eq-without-hash, - div-method, - idiv-method, - rdiv-method, - exception-message-attribute, - invalid-str-codec, - sys-max-int, - bad-python3-import, - deprecated-string-function, - deprecated-str-translate-call, - deprecated-itertools-function, - deprecated-types-field, - next-method-defined, - dict-items-not-iterating, - dict-keys-not-iterating, - dict-values-not-iterating, - deprecated-operator-function, - deprecated-urllib-function, - xreadlines-attribute, - deprecated-sys-function, - exception-escape, - comprehension-escape, - bad-whitespace, # new disabled errors no-name-in-module, trailing-newlines, missing-function-docstring, @@ -257,7 +186,7 @@ function-naming-style=camelCase # Good variable names which should always be accepted, separated by a comma. good-names=_ - + # Good variable names regexes, separated by a comma. If names match any regex, # they will always be accepted good-names-rgxs=[a-z],[a-z][a-z0-9] @@ -328,13 +257,6 @@ max-line-length=120 # Maximum number of lines in a module. max-module-lines=1000 -# List of optional constructs for which whitespace checking is disabled. `dict- -# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. -# `trailing-comma` allows a space between comma and closing bracket: (a, ). -# `empty-line` allows space-only lines. -no-space-check=trailing-comma, - dict-separator - # Allow the body of a class to be on the same line as the declaration if body # contains single statement. single-line-class-stmt=no diff --git a/rpn/makeHelp.py b/rpn/makeHelp.py index c193321..e027cd7 100644 --- a/rpn/makeHelp.py +++ b/rpn/makeHelp.py @@ -55,9 +55,9 @@ PROGRAM_NAME = 'makeHelp' PROGRAM_DESCRIPTION = 'rpnChilada help generator' -MAX_EXAMPLE_COUNT = 2445 # This needs to be manually updated when the help examples are modified. +MAX_EXAMPLE_COUNT = 2451 # This needs to be manually updated when the help examples are modified. -os.chdir( getUserDataPath( ) ) # SkyField doesn't like running in the root directory +os.chdir( getUserDataPath( ) ) # SkyField doesn't like running in the root directory startTime = time_ns( ) @@ -1402,7 +1402,7 @@ def makeCommandExample( command, indent=0, slow=False ): tzwhere has been replaced with timezonefinder. -The 'change_digits' operator was added. +The 'change_digits' operator was added. And finally after about 8 years (since version 6.4.0), the Windows binary is back! diff --git a/rpn/math/rpnNumberTheory.py b/rpn/math/rpnNumberTheory.py index 3f3f3dd..0cba1fb 100644 --- a/rpn/math/rpnNumberTheory.py +++ b/rpn/math/rpnNumberTheory.py @@ -1049,8 +1049,8 @@ def makePythagoreanTriplesOperator( n ): @argValidator( [ IntValidator( 1 ), IntValidator( 1 ) ] ) def makePythagoreanQuadrupleOperator( a, b ): # pylint: disable=invalid-name - odd1 = ( fmod( a, 2 ) == 1 ) - odd2 = ( fmod( b, 2 ) == 1 ) + odd1 = fmod( a, 2 ) == 1 + odd2 = fmod( b, 2 ) == 1 if odd1 and odd2: raise ValueError( "'make_pyth_4' arguments cannot both be odd" ) diff --git a/rpn/math/rpnPolytope.py b/rpn/math/rpnPolytope.py index 6be28f3..ca2f9e4 100644 --- a/rpn/math/rpnPolytope.py +++ b/rpn/math/rpnPolytope.py @@ -27,7 +27,7 @@ #****************************************************************************** def getNthGeneralizedPolygonalNumber( n, k ): - negative = ( fmod( n, 2 ) == 0 ) + negative = fmod( n, 2 ) == 0 n = floor( fdiv( fadd( n, 1 ), 2 ) ) diff --git a/rpn/rpnOperators.py b/rpn/rpnOperators.py index 5d24ef1..021fcbd 100644 --- a/rpn/rpnOperators.py +++ b/rpn/rpnOperators.py @@ -230,7 +230,7 @@ isHarmonicDivisorNumberOperator, isKHyperperfectOperator, isKPerfectOperator, isKPolydivisibleOperator, \ isKSemiprimeOperator, isKSphenicOperator, isPerfectOperator, isPerniciousOperator, isPolite, \ isPolydivisibleOperator, isPowerfulOperator, isPronicOperator, isRoughOperator, isRuthAaronNumberOperator, \ - isSemiprimeOperator, isSmoothOperator, isSociableListOperator, isSphenicOperator, isSquareFreeOperator, \ + isSemiprimeOperator, isSmoothOperator, isSphenicOperator, isSquareFreeOperator, \ isUnusualOperator, makeContinuedFractionOperator, makeEulerBrickOperator, makePythagoreanQuadrupleOperator, \ makePythagoreanTripleOperator, makePythagoreanTriplesOperator, solveFrobeniusOperator, getVanEckOperator diff --git a/rpn/science/rpnPhysics.py b/rpn/science/rpnPhysics.py index fb29d72..dfe4480 100644 --- a/rpn/science/rpnPhysics.py +++ b/rpn/science/rpnPhysics.py @@ -108,7 +108,7 @@ def calculateBlackHoleMass( measurement ): if 'time' in arguments: lifetime = arguments[ 'time' ] - return getRoot( divide( getProduct( [ lifetime, mpmathify( "1.8083" ), + return getRoot( divide( getProduct( [ lifetime, mpmathify( '1.8083' ), getConstant( 'reduced_planck_constant' ), getPower( getConstant( 'speed_of_light' ), 4 ) ] ), getProduct( [ 5120, pi, diff --git a/rpn/special/rpnLocation.py b/rpn/special/rpnLocation.py index f46cddd..4a6456a 100644 --- a/rpn/special/rpnLocation.py +++ b/rpn/special/rpnLocation.py @@ -25,7 +25,7 @@ from rpn.time.rpnDateTimeClass import RPNDateTime from rpn.units.rpnMeasurementClass import RPNMeasurement -from rpn.special.rpnLocationLookup import loadLocationCache, saveLocationCache, lookUpLocation +from rpn.special.rpnLocationLookup import lookUpLocation from rpn.special.rpnLocationLookup import lookUpTimeZone from rpn.util.rpnUtils import oneArgFunctionEvaluator, twoArgFunctionEvaluator @@ -67,9 +67,6 @@ def getLocation( name ): result.setLat( latitude ) result.setLong( longitude ) - g.locationCache[ name ] = [ name, result.getLat( ), result.getLong( ) ] - saveLocationCache( g.locationCache ) - return result diff --git a/rpn/special/rpnLocationLookup.py b/rpn/special/rpnLocationLookup.py index 48dbbab..f228474 100644 --- a/rpn/special/rpnLocationLookup.py +++ b/rpn/special/rpnLocationLookup.py @@ -91,6 +91,9 @@ def lookUpLocation( name ): if location is None: raise ValueError( 'location lookup failed, try a different search term' ) + g.locationCache[ name ] = [ name, location.latitude, location.longitude ] + saveLocationCache( g.locationCache ) + return location.latitude, location.longitude diff --git a/rpn/util/rpnOutput.py b/rpn/util/rpnOutput.py index 7137b24..6de672c 100644 --- a/rpn/util/rpnOutput.py +++ b/rpn/util/rpnOutput.py @@ -43,7 +43,7 @@ #****************************************************************************** def formatNumber( number, outputRadix, leadingZero, integerGrouping, integerDelimiter, decimalDelimiter ): - negative = ( number < 0 ) + negative = number < 0 if outputRadix == g.fibBase: strInteger = convertToFibBase( floor( number ) )