CDLUC3 / ezid

CDLUC3 ezid
MIT License
10 stars 4 forks source link

Fix deprecated Python practices - part 2 fix flake8 reported issues #734

Open jsjiang opened 2 months ago

jsjiang commented 2 months ago

Starting the EZID runserver with Python [-Wd] option reported a few deprecated interfaces warnings. Running pylint and flake8 against the EZID project reported over 11K and 5K items respectively. Review the reported items and provide fixes if possible.

Note:

jsjiang commented 1 month ago

Outputs from flake8:

  1. Formatting related - low priority

E111 indentation is not a multiple of 4 E115 expected an indented block (comment) E117 over-indented E122 continuation line missing indentation or outdented E127 continuation line over-indented for visual indent E131 continuation line unaligned for hanging indent E202 whitespace before ')' E202 whitespace before '}' E203 whitespace before ' E211 whitespace before '(' E221 multiple spaces before operator E222 multiple spaces after operator E225 missing whitespace around operator E231 missing whitespace after ' E231 missing whitespace after ',' E251 unexpected spaces around keyword / parameter equals E252 missing whitespace around parameter equals E261 at least two spaces before inline comment E262 inline comment should start with '# ' E265 block comment should start with '# ' E266 too many leading '#' for block comment E271 multiple spaces after keyword E272 multiple spaces before keyword E275 missing whitespace after keyword E302 expected 2 blank lines, found 1 E303 too many blank lines (6) E305 expected 2 blank lines after class or function definition, found 1 E402 module level import not at top of file E501 line too long (100 > 79 characters) W291 trailing whitespace W292 no newline at end of file W293 blank line contains whitespace W391 blank line at end of file

  1. Style related (medium priority) - #760

E703 statement ends with a semicolon E712 comparison to False should be 'if cond is False E712 comparison to True should be 'if cond is True E713 test for membership should be 'not in' E714 test for object identity should be 'is not' E721 do not compare types, for exact checks use is / is not, for instance checks use isinstance() E722 do not use bare 'except' E741 ambiguous variable name 'l'

  1. Variable related
    • F821 undefined name - high priority - dropped priority to medium after investigation - #759
    • F522 format(...) has unused named argument(s) - investigate - medium priority #756
    • F523 format(...) has unused arguments at position(s) - investigate - medium priority #758
    • F541 f-string is missing placeholders - investigate - can be ignored
    • sample code logger.debug(f'Using identifier for owner and group.')
    • F601 dictionary key 'matomo_site_id' repeated with different values - investigate - medium priority #757
    • F401 imported but unused - low priority
    • F811 redefinition of unused xxx - low priority
    • F841 local variable X is assigned to but never used - low priority

F401 '.minter.Minter' imported but unused F401 '.proc_base.AsyncProcessingError' imported but unused ... F401 'zlib' imported but unused F522 '...'.format(...) has unused named argument(s) F523 '...'.format(...) has unused arguments at position(s) F541 f-string is missing placeholders F601 dictionary key 'matomo_site_id' repeated with different values F811 redefinition of unused 'django' from line 16 F811 redefinition of unused 'django' from line 19 F811 redefinition of unused 'ezidapp' from line 25 F811 redefinition of unused 'ezidapp' from line 32 F811 redefinition of unused 'patch' from line 2 F811 redefinition of unused 'registration_queue' from line 555 F811 redefinition of unused 'settings' from line 5 F821 undefined name 'django' F821 undefined name 'lastM' F821 undefined name 'lastMonth' F841 local variable '_d' is assigned to but never used F841 local variable '_default_key' is assigned to but never used F841 local variable '_dlm' is assigned to but never used F841 local variable '_e' is assigned to but never used F841 local variable '_exclusionFile' is assigned to but never used F841 local variable '_exclusionFileModifyTime' is assigned to but never used F841 local variable '_function' is assigned to but never used F841 local variable '_lastExclusionFileCheckTime' is assigned to but never used F841 local variable '_match' is assigned to but never used F841 local variable '_module' is assigned to but never used F841 local variable '_month_earliest' is assigned to but never used F841 local variable '_month_latest' is assigned to but never used F841 local variable '_n' is assigned to but never used F841 local variable '_permanentExcludes' is assigned to but never used F841 local variable '_table' is assigned to but never used F841 local variable '_temporaryExcludes' is assigned to but never used F841 local variable 'data' is assigned to but never used F841 local variable 'e' is assigned to but never used F841 local variable 'exc_info' is assigned to but never used F841 local variable 'ezid_uri' is assigned to but never used F841 local variable 'fixture_dir_path' is assigned to but never used F841 local variable 'id_model' is assigned to but never used F841 local variable 'identifier_class' is assigned to but never used F841 local variable 'is_valid' is assigned to but never used F841 local variable 'lastM' is assigned to but never used F841 local variable 'len' is assigned to but never used F841 local variable 'link_checker_model' is assigned to but never used F841 local variable 'max_list' is assigned to but never used F841 local variable 'mock_get' is assigned to but never used F841 local variable 'result_list' is assigned to but never used F841 local variable 'scopeRequirementMet' is assigned to but never used

  1. Invalid escape sequence - medium priority - #761

W605 invalid escape sequence '\$' W605 invalid escape sequence '(' W605 invalid escape sequence ')' W605 invalid escape sequence '.' W605 invalid escape sequence '\/' W605 invalid escape sequence '>' W605 invalid escape sequence '\?' W605 invalid escape sequence '\d' W605 invalid escape sequence '\s' W605 invalid escape sequence '\w'