From 0f9daf1ef2897bc314a66f58469c20184c9e3f0c Mon Sep 17 00:00:00 2001 From: Jesse Nusbaumer Date: Wed, 25 Aug 2021 20:58:43 -0600 Subject: [PATCH] Fix pylint errors. --- cime_config/buildnml | 5 ++--- test/unit/cam_config_unit_tests.py | 18 +++++++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/cime_config/buildnml b/cime_config/buildnml index 10471f93..83797d4d 100755 --- a/cime_config/buildnml +++ b/cime_config/buildnml @@ -61,8 +61,8 @@ def nml_attr_set(config): set namelist defaults. """ - #Create new namelist attribute dictionary: - cam_nml_attr_dict = dict() + #Create new (empty) namelist attribute dictionary: + cam_nml_attr_dict = {} if config: #Loop over all CAM configuration settings in config dictionary: @@ -98,7 +98,6 @@ def buildnml(case, caseroot, compname): # End if srcroot = case.get_value("SRCROOT") rundir = case.get_value("RUNDIR") - din_loc_root = case.get_value("DIN_LOC_ROOT") atm_ncpl = case.get_value("ATM_NCPL") cam_namelist_opts = case.get_value("CAM_NAMELIST_OPTS") cam_nml_use_case = case.get_value("CAM_NML_USE_CASE") diff --git a/test/unit/cam_config_unit_tests.py b/test/unit/cam_config_unit_tests.py index 5c98a054..0f4e82cc 100644 --- a/test/unit/cam_config_unit_tests.py +++ b/test/unit/cam_config_unit_tests.py @@ -306,11 +306,11 @@ def test_config_ccpp_phys_set_check_single_suite(self): #Set "new" physics_suites value with one physics suite: self.test_config_cam.set_value("physics_suites", "kessler") - #Create namelist attribute dictionary: - cam_nml_attr_dict = dict() + #Create (empty) namelist attribute dictionary: + cam_nml_attr_dict = {} #Create namelist file: - with open("test.txt", "w") as test_fil: + with open("test.txt", "w", encoding='UTF-8') as test_fil: test_fil.write('!Namelist test file\n') test_fil.write('physics_suite = "adiabatic"\n') @@ -343,7 +343,7 @@ def test_config_ccpp_phys_set_check_multi_suite(self): cam_nml_attr_dict = dict() #Create namelist file: - with open("test.txt", "w") as test_fil: + with open("test.txt", "w", encoding='UTF-8') as test_fil: test_fil.write('!Namelist test file\n') test_fil.write('physics_suite = "adiabatic"\n') @@ -377,7 +377,7 @@ def test_config_ccpp_phys_set_missing_phys(self): ermsg += "in CAM_CONFIG_OPTS." #Create namelist file: - with open("test.txt", "w") as test_fil: + with open("test.txt", "w", encoding='UTF-8') as test_fil: test_fil.write('!Namelist test file\n') #Expect "CamConfigValError": @@ -412,7 +412,7 @@ def test_config_ccpp_phys_set_two_phys(self): ermsg += "Only one 'physics_suite' line is allowed." #Create namelist file: - with open("test.txt", "w") as test_fil: + with open("test.txt", "w", encoding='UTF-8') as test_fil: test_fil.write('!Namelist test file\n') test_fil.write('physics_suite = "adiabatic"\n') test_fil.write('physics_suite = "kessler"\n') @@ -449,7 +449,7 @@ def test_config_ccpp_phys_set_missing_equals(self): #Create namelist file: - with open("test.txt", "w") as test_fil: + with open("test.txt", "w", encoding='UTF-8') as test_fil: test_fil.write('!Namelist test file\n') test_fil.write('physics_suite "adiabatic"\n') @@ -484,7 +484,7 @@ def test_config_ccpp_phys_set_two_equals(self): ermsg = "There must only be one equals (=) sign in the 'physics_suite' namelist line." #Create namelist file: - with open("test.txt", "w") as test_fil: + with open("test.txt", "w", encoding='UTF-8') as test_fil: test_fil.write('!Namelist test file\n') test_fil.write('physics_suite == "adiabatic"\n') @@ -522,7 +522,7 @@ def test_config_ccpp_phys_set_no_physics_suite_match(self): ermsg += "listed in CAM_CONFIG_OPTS" #Create namelist file: - with open("test.txt", "w") as test_fil: + with open("test.txt", "w", encoding='UTF-8') as test_fil: test_fil.write('!Namelist test file\n') test_fil.write('physics_suite = "cam6"\n')