Add check before iterating over dist.requires at load_instrumentor (#3168)
* Add check before iterate over dist.requires * Changelog * Add test
This commit is contained in:
		
							parent
							
								
									3d5935f4f6
								
							
						
					
					
						commit
						147e3f754e
					
				|  | @ -32,6 +32,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
| 
 | ||||
| - `opentelemetry-instrumentation-httpx` Fix `RequestInfo`/`ResponseInfo` type hints | ||||
|   ([#3105](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3105)) | ||||
| - `opentelemetry-instrumentation` Fix `get_dist_dependency_conflicts` if no distribution requires | ||||
|   ([#3168](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3168)) | ||||
| 
 | ||||
| 
 | ||||
| ## Version 1.29.0/0.50b0 (2024-12-11) | ||||
|  |  | |||
|  | @ -47,6 +47,7 @@ def get_dist_dependency_conflicts( | |||
|     extra = "extra" | ||||
|     instruments = "instruments" | ||||
|     instruments_marker = {extra: instruments} | ||||
|     if dist.requires: | ||||
|         for dep in dist.requires: | ||||
|             if extra not in dep or instruments not in dep: | ||||
|                 continue | ||||
|  |  | |||
|  | @ -86,3 +86,19 @@ class TestDependencyConflicts(TestBase): | |||
|             str(conflict), | ||||
|             'DependencyConflict: requested: "test-pkg~=1.0; extra == "instruments"" but found: "None"', | ||||
|         ) | ||||
| 
 | ||||
|     def test_get_dist_dependency_conflicts_requires_none(self): | ||||
|         class MockDistribution(Distribution): | ||||
|             def locate_file(self, path): | ||||
|                 pass | ||||
| 
 | ||||
|             def read_text(self, filename): | ||||
|                 pass | ||||
| 
 | ||||
|             @property | ||||
|             def requires(self): | ||||
|                 return None | ||||
| 
 | ||||
|         dist = MockDistribution() | ||||
|         conflict = get_dist_dependency_conflicts(dist) | ||||
|         self.assertTrue(conflict is None) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue