@@ -127,31 +127,23 @@ def get_results(
127127 kwargs = _check_kwargs (kwargs )
128128
129129 if legacy is True :
130- if (
131- "dataProfile" in kwargs
132- and kwargs ["dataProfile" ] not in result_profiles_legacy
133- ):
134- raise TypeError (
135- f"dataProfile { kwargs ['dataProfile' ]} is not a legacy profile." ,
136- f"Valid options are { result_profiles_legacy } ." ,
137- )
138-
130+ valid_profiles = result_profiles_legacy
131+ kind = "legacy"
139132 url = wqp_url ("Result" )
140-
141133 else :
142- if (
143- "dataProfile" in kwargs
144- and kwargs ["dataProfile" ] not in result_profiles_wqx3
145- ):
146- raise TypeError (
147- f"dataProfile { kwargs ['dataProfile' ]} is not a valid WQX3.0"
148- f"profile. Valid options are { result_profiles_wqx3 } ." ,
149- )
150- else :
151- kwargs ["dataProfile" ] = "fullPhysChem"
152-
134+ valid_profiles = result_profiles_wqx3
135+ kind = "WQX3.0"
153136 url = wqx3_url ("Result" )
154137
138+ profile = kwargs .get ("dataProfile" )
139+ if profile is not None and profile not in valid_profiles :
140+ raise ValueError (
141+ f"dataProfile { profile !r} is not a valid { kind } profile. "
142+ f"Valid options are { valid_profiles } ."
143+ )
144+ if legacy is not True and profile is None :
145+ kwargs ["dataProfile" ] = "fullPhysChem"
146+
155147 response = query (url , kwargs , delimiter = ";" , ssl_check = ssl_check )
156148
157149 df = pd .read_csv (StringIO (response .text ), delimiter = "," , low_memory = False )
0 commit comments