Commit 22de1c1
fix(flask): stop reading deprecated flask.__version__ (#4422)
* fix(flask): stop reading deprecated flask.__version__
Flask 3.1 deprecated the module-level __version__ attribute and emits a
DeprecationWarning on access; 3.2 will remove it. The Flask
instrumentor was hitting that warning at import time via
_IS_FLASK_31_PLUS = hasattr(flask, "__version__") and
package_version.parse(flask.__version__) >= package_version.parse("3.1.0")
even though it already computes the installed Flask version via
importlib.metadata.version("flask") a few lines below. Use that
flask_version for the 3.1+ check and drop the deprecated attribute
access entirely.
Fixes #4402
Signed-off-by: Ali <alliasgher123@gmail.com>
* style: apply ruff format
Signed-off-by: alliasgher <alliasgher123@gmail.com>
* fix(flask): also stop reading deprecated flask.__version__ in tests
Per @xrmx review — the test suite was the remaining caller of the
deprecated attribute. Switch to importlib.metadata.version("flask")
to match the production code change.
Signed-off-by: alliasgher <alliasgher123@gmail.com>
* Apply suggestions from code review
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* Update CHANGELOG.md
---------
Signed-off-by: Ali <alliasgher123@gmail.com>
Signed-off-by: alliasgher <alliasgher123@gmail.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>1 parent 1190dfc commit 22de1c1
3 files changed
Lines changed: 9 additions & 5 deletions
File tree
- instrumentation/opentelemetry-instrumentation-flask
- src/opentelemetry/instrumentation/flask
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| |||
Lines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | 304 | | |
309 | 305 | | |
310 | 306 | | |
| |||
316 | 312 | | |
317 | 313 | | |
318 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
319 | 320 | | |
320 | 321 | | |
321 | 322 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
40 | | - | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
0 commit comments