@@ -134,6 +134,13 @@ def get_dependency_conflicts(
134134 # TODO: dangerous
135135 ] = None , # Dependencies any of which are required
136136) -> DependencyConflict | None :
137+ # instruments_conflict = get_dependency_conflicts()
138+ # if instruments_conflict:
139+ # return instruments_conflict
140+
141+ # instruments_either_conflict = get_dependency_conflicts_either()
142+ # return instruments_either_conflict
143+
137144 for dep in deps :
138145 # TODO: what is this?
139146 if isinstance (dep , Requirement ):
@@ -162,53 +169,62 @@ def get_dependency_conflicts(
162169 return DependencyConflict (dep , f"{ req .name } { dist_version } " )
163170
164171 # TODO: add eval of deps_either
172+ # If all the dependencies in "instruments" are present, check "instruments_either" for conflicts.
165173 if deps_either :
166- # TODO: change to using DependencyConflict
167- is_dependency_conflict = True
168- required_either : Collection [str ] = []
169- found_either : Collection [str ] = []
170- for dep in deps_either :
171- # TODO: what is this?
172- if isinstance (dep , Requirement ):
173- print ("REQUIREMENT" )
174- req = dep
175- else :
176- try :
177- print ("NOT REQUIREMENT" )
178- req = Requirement (dep )
179- except InvalidRequirement as exc :
180- logger .warning (
181- 'error parsing dependency, reporting as a conflict: "%s" - %s' ,
182- dep ,
183- exc ,
184- )
185- return DependencyConflict (dep )
174+ return _get_dependency_conflicts_either (deps_either )
175+ return None
186176
187- try :
188- dist_version = version (req .name )
189- except PackageNotFoundError :
190- # print(f"PackageNotFoundError EITHER: {req.name}")
191- # TODO: anything here?
192- # return DependencyConflict(dep)
193- required_either .append (str (dep ))
194- continue
195177
196- if req .specifier .contains (dist_version ):
197- # Since only one of the instrumentation_either dependencies is required, there is no dependency conflict.
198- is_dependency_conflict = False
199- break
200- # If the version does not match, add it to the list of unfulfilled requirement options.
201- required_either .append (str (dep ))
202- found_either .append (f"{ req .name } { dist_version } " )
203-
204- if is_dependency_conflict :
205- # return DependencyConflict(dep, f"{req.name} {dist_version}")
206- # print (f"required_either: {required_either}")
207- # print (f"found_either: {found_either}")
208- return DependencyConflict (
209- required_either = required_either ,
210- found_either = found_either ,
211- )
178+ # This is a helper functions designed to ease reading and meet linting requirements.
179+ def _get_dependency_conflicts_either (
180+ deps_either : Collection [str | Requirement ],
181+ ) -> DependencyConflict | None :
182+ if not deps_either :
212183 return None
184+ # TODO: change to using DependencyConflict
185+ is_dependency_conflict = True
186+ required_either : Collection [str ] = []
187+ found_either : Collection [str ] = []
188+ for dep in deps_either :
189+ # TODO: what is this?
190+ if isinstance (dep , Requirement ):
191+ print ("REQUIREMENT" )
192+ req = dep
193+ else :
194+ try :
195+ print ("NOT REQUIREMENT" )
196+ req = Requirement (dep )
197+ except InvalidRequirement as exc :
198+ logger .warning (
199+ 'error parsing dependency, reporting as a conflict: "%s" - %s' ,
200+ dep ,
201+ exc ,
202+ )
203+ return DependencyConflict (dep )
213204
205+ try :
206+ dist_version = version (req .name )
207+ except PackageNotFoundError :
208+ # print(f"PackageNotFoundError EITHER: {req.name}")
209+ # TODO: anything here?
210+ # return DependencyConflict(dep)
211+ required_either .append (str (dep ))
212+ continue
213+
214+ if req .specifier .contains (dist_version ):
215+ # Since only one of the instrumentation_either dependencies is required, there is no dependency conflict.
216+ is_dependency_conflict = False
217+ break
218+ # If the version does not match, add it to the list of unfulfilled requirement options.
219+ required_either .append (str (dep ))
220+ found_either .append (f"{ req .name } { dist_version } " )
221+
222+ if is_dependency_conflict :
223+ # return DependencyConflict(dep, f"{req.name} {dist_version}")
224+ # print (f"required_either: {required_either}")
225+ # print (f"found_either: {found_either}")
226+ return DependencyConflict (
227+ required_either = required_either ,
228+ found_either = found_either ,
229+ )
214230 return None
0 commit comments