Skip to content

Commit

Permalink
fix deprecation warning for __version__ (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
yctomwang authored Jan 30, 2024
1 parent a33e151 commit 4ace0d3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
import json
import sys
from datetime import date
from datetime import timedelta

import pytest
from dateutil.relativedelta import relativedelta
from flask import __version__ as flask_version
from flask import Flask

from flask_jwt_extended import JWTManager
from flask_jwt_extended.config import config
from flask_jwt_extended.internal_utils import JSONEncoder


def get_package_version(package_name):
if sys.version_info >= (3, 8):
# Use importlib.metadata for Python 3.8 and newer
import importlib.metadata

return importlib.metadata.version(package_name)
else:
# Use pkg_resources for older versions
import pkg_resources

return pkg_resources.get_distribution(package_name).version


flask_version = get_package_version("flask")
flask_version_tuple = tuple(map(int, flask_version.split(".")))


Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ deps =
python-dateutil
types-python-dateutil
mypy
types-setuptools

[testenv:coverage]
commands =
Expand Down

0 comments on commit 4ace0d3

Please sign in to comment.