Skip to content

Fix used-before-assignment and possibly-used-before-assignment issues detected with recent pylint versions #4857

@billsacks

Description

@billsacks

In trying to update to the latest version of pylint (#4856 ), I saw that this latest version detects a lot of possible issues that were previously going undetected. Most of these are used-before-assignment and possibly-used-before-assignment. I haven't investigated these carefully, but the ones I've glanced at seem to arise from some (theoretical, at least) combination of logical conditions that can lead to an attempted use of an undefined variable (e.g., the variable is defined if X and used if Y; or it is defined one way if A, another if B, and another if C (with no else clause), and then used always).

If we want to update to a more recent pylint, we will either need to fix these issues or disable these checks. I'd vote against disabling them long-term, but would be okay with disabling them short-term and then incrementally resolving them.

************* Module CIME.SystemTests.system_tests_common
CIME/SystemTests/system_tests_common.py:192:21: E0606: Possibly using variable 'timestep' before assignment (possibly-used-before-assignment)
CIME/SystemTests/system_tests_common.py:203:40: E0606: Possibly using variable 'coupling_secs' before assignment (possibly-used-before-assignment)
CIME/SystemTests/system_tests_common.py:251:39: E0606: Possibly using variable 'rtd' before assignment (possibly-used-before-assignment)
************* Module CIME.XML.compsets
CIME/XML/compsets.py:88:25: E0606: Possibly using variable 'alias' before assignment (possibly-used-before-assignment)
CIME/XML/compsets.py:88:34: E0606: Possibly using variable 'lname' before assignment (possibly-used-before-assignment)
************* Module CIME.XML.env_batch
CIME/XML/env_batch.py:562:32: E0606: Possibly using variable 'default_queue' before assignment (possibly-used-before-assignment)
************* Module CIME.XML.namelist_definition
CIME/XML/namelist_definition.py:139:15: E0606: Possibly using variable 'group' before assignment (possibly-used-before-assignment)
CIME/XML/namelist_definition.py:146:15: E0606: Possibly using variable 'type_info' before assignment (possibly-used-before-assignment)
CIME/XML/namelist_definition.py:502:15: E0606: Possibly using variable 'input_pathname' before assignment (possibly-used-before-assignment)
************* Module CIME.XML.workflow
CIME/XML/workflow.py:83:29: E0606: Possibly using variable 'name' before assignment (possibly-used-before-assignment)
************* Module CIME.case.case_setup
CIME/case/case_setup.py:331:19: E0606: Possibly using variable 'ninst' before assignment (possibly-used-before-assignment)
************* Module CIME.case.case_submit
CIME/case/case_submit.py:362:30: E0606: Possibly using variable 'timestep' before assignment (possibly-used-before-assignment)
CIME/case/case_submit.py:366:23: E0606: Possibly using variable 'coupling_secs' before assignment (possibly-used-before-assignment)
************* Module CIME.case.check_input_data
CIME/case/check_input_data.py:45:15: E0606: Possibly using variable 'server' before assignment (possibly-used-before-assignment)
CIME/case/check_input_data.py:212:34: E0601: Using variable 'chksum_found' before assignment (used-before-assignment)
CIME/case/check_input_data.py:425:15: E0606: Possibly using variable 'server' before assignment (possibly-used-before-assignment)
************* Module CIME.compare_test_results
CIME/compare_test_results.py:188:20: E0601: Using variable 'compare_result' before assignment (used-before-assignment)
CIME/compare_test_results.py:190:19: E0601: Using variable 'compare_comment' before assignment (used-before-assignment)
************* Module CIME.get_timing
CIME/get_timing.py:422:30: E0606: Possibly using variable 'binfilename' before assignment (possibly-used-before-assignment)
CIME/get_timing.py:429:31: E0606: Possibly using variable 'finfilename' before assignment (possibly-used-before-assignment)
CIME/get_timing.py:458:16: E0606: Possibly using variable 'nsteps' before assignment (possibly-used-before-assignment)
CIME/get_timing.py:613:67: E0606: Possibly using variable 'nmax' before assignment (possibly-used-before-assignment)
CIME/get_timing.py:620:67: E0606: Possibly using variable 'fmax' before assignment (possibly-used-before-assignment)
************* Module CIME.hist_utils
CIME/hist_utils.py:558:12: E0606: Possibly using variable 'files_match' before assignment (possibly-used-before-assignment)
************* Module CIME.namelist
CIME/namelist.py:1251:56: E0606: Possibly using variable 'equals' before assignment (possibly-used-before-assignment)
************* Module CIME.scripts.configure
CIME/scripts/configure:116:22: E0606: Possibly using variable 'machobj' before assignment (possibly-used-before-assignment)
************* Module CIME.test_utils
CIME/test_utils.py:71:24: E0606: Possibly using variable 'thismach' before assignment (possibly-used-before-assignment)
CIME/test_utils.py:72:25: E0606: Possibly using variable 'thiscompiler' before assignment (possibly-used-before-assignment)
************* Module CIME.utils
CIME/utils.py:2690:21: E0606: Possibly using variable 'model' before assignment (possibly-used-before-assignment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions