Skip to content

Commit

Permalink
Merge pull request #2453 from samuelhwilliams/update-python-versions
Browse files Browse the repository at this point in the history
Remove python 3.7 compatibility; add python 3.12
  • Loading branch information
samuelhwilliams authored Jul 16, 2024
2 parents 18b2c94 + 3da262f commit 5a75ad3
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 276 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ['3.7', '3.8', '3.9', '3.10', '3.11']
python: ['3.8', '3.9', '3.10', '3.11', '3.12']
wtforms: ['2']
services:
# Label used to access the service container
Expand Down
11 changes: 10 additions & 1 deletion flask_admin/contrib/fileadmin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import sys
import warnings
from datetime import datetime
import os
import os.path as op
import platform
import re
import shutil
from functools import partial
from operator import itemgetter
from urllib.parse import urljoin, quote

Expand All @@ -19,6 +21,13 @@
from flask_admin.babel import gettext, lazy_gettext


if sys.version_info >= (3, 11):
from datetime import UTC
utc_fromtimestamp = partial(datetime.fromtimestamp, tz=UTC)
else:
utc_fromtimestamp = datetime.utcfromtimestamp


class LocalFileStorage(object):
def __init__(self, base_path):
"""
Expand Down Expand Up @@ -857,7 +866,7 @@ def index_view(self, path=None):
items.sort(key=itemgetter(2), reverse=True)
if not self._on_windows:
# Sort by modified date
items.sort(key=lambda x: (x[0], x[1], x[2], x[3], datetime.utcfromtimestamp(x[4])), reverse=True)
items.sort(key=lambda x: (x[0], x[1], x[2], x[3], utc_fromtimestamp(x[4])), reverse=True)
else:
items.sort(key=itemgetter(column_index), reverse=sort_desc)

Expand Down
23 changes: 16 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ classifiers = [
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Software Development :: Libraries :: Python Modules',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
]
requires-python = ">=3.6"
dependencies = [
Expand Down Expand Up @@ -47,8 +46,19 @@ filterwarnings = [
# TODO: remove the ignored deprecation warning when support for WTForms 3 has been added.
"ignore:Flags should be stored in dicts and not in tuples. The next version of WTForms will abandon support for flags in tuples.:DeprecationWarning",
"ignore:'HTMLString' will be removed in WTForms 3.0. Use 'markupsafe.Markup' instead.:DeprecationWarning",
# TODO: remove when we drop Python 3.7 support
"ignore:pkg_resources is deprecated as an API:DeprecationWarning",

# flask-mongoengine is responsible for the below deprecation warning, and hasn't been updated recently
"default:No uuidRepresentation is specified:DeprecationWarning",

# Werkzeug is responsible for the below deprecation warning; remove when they have updated their code.
"default:ast\\.Str is deprecated and will be removed in Python 3\\.14:DeprecationWarning",
"default:Attribute s is deprecated and will be removed in Python 3\\.14:DeprecationWarning",

# Flask is responsible for the below deprecation warning; remove when they have updated their code.
"default:'pkgutil\\.get_loader' is deprecated and slated for removal in Python 3\\.14:DeprecationWarning",
"default:'pkgutil\\.find_loader' is deprecated and slated for removal in Python 3\\.14:DeprecationWarning",

"default:datetime\\.datetime\\.utcnow\\(\\) is deprecated and scheduled for removal in a future version:DeprecationWarning"
]

[tool.coverage.run]
Expand All @@ -59,7 +69,7 @@ source = ["flask_admin", "tests"]
source = ["flask_admin", "*/site-packages"]

[tool.mypy]
python_version = "3.6"
python_version = "3.8"
files = ["flask_admin"]
show_error_codes = true
pretty = true
Expand Down Expand Up @@ -111,7 +121,6 @@ module = [
"mongoengine.*",
"playhouse.*",
"pymongo",
"shapely.*", # types-shapely requires python 3.8+
"sqlalchemy.*",
"sqlalchemy_enum34",
"sqlalchemy_utils",
Expand All @@ -123,7 +132,7 @@ module = [
ignore_missing_imports = true

[tool.pyright]
pythonVersion = "3.6"
pythonVersion = "3.8"
include = ["flask_admin", "tests"]
typeCheckingMode = "basic"

Expand Down
4 changes: 1 addition & 3 deletions requirements/build.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.7
# This file is autogenerated by pip-compile with Python 3.8
# by the following command:
#
# pip-compile build.in
Expand All @@ -14,7 +14,5 @@ pyproject-hooks==1.1.0
# via build
tomli==2.0.1
# via build
typing-extensions==4.7.1
# via importlib-metadata
zipp==3.15.0
# via importlib-metadata
40 changes: 16 additions & 24 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# This file is autogenerated by pip-compile with Python 3.7
# This file is autogenerated by pip-compile with Python 3.8
# by the following command:
#
# pip-compile --resolver=backtracking dev.in
# pip-compile dev.in
#
alabaster==0.7.13
# via
Expand Down Expand Up @@ -32,6 +32,7 @@ azure-storage-common==2.1.0
babel==2.9.1
# via
# -r docs.txt
# -r tests.in
# -r typing.txt
# flask-babelex
# sphinx
Expand Down Expand Up @@ -68,7 +69,6 @@ colour==0.1.5
coverage[toml]==6.5.0
# via
# -r typing.txt
# coverage
# coveralls
# pytest-cov
coveralls==3.3.1
Expand Down Expand Up @@ -156,18 +156,8 @@ importlib-metadata==6.7.0
# via
# -r docs.txt
# -r typing.txt
# click
# flake8
# flask
# pallets-sphinx-themes
# pluggy
# pre-commit
# pytest
# sphinx
# sqlalchemy
# sqlalchemy-utils
# tox
# virtualenv
iniconfig==2.0.0
# via
# -r typing.txt
Expand All @@ -185,6 +175,7 @@ itsdangerous==2.0.1
jinja2==3.0.0
# via
# -r docs.txt
# -r tests.in
# -r typing.txt
# flask
# flask-babelex
Expand All @@ -196,8 +187,10 @@ lazy-object-proxy==1.9.0
markupsafe==2.0.1
# via
# -r docs.txt
# -r tests.in
# -r typing.txt
# jinja2
# types-wtforms
# wtforms
mccabe==0.6.1
# via
Expand All @@ -220,6 +213,11 @@ nodeenv==1.9.1
# -r typing.txt
# pre-commit
# pyright
numpy==1.24.4
# via
# -r typing.txt
# shapely
# types-shapely
packaging==24.0
# via
# -r docs.txt
Expand Down Expand Up @@ -315,7 +313,7 @@ requests==2.31.0
# azure-storage-common
# coveralls
# sphinx
shapely==1.8.5.post1
shapely==2.0.5
# via
# -r tests.in
# -r typing.txt
Expand Down Expand Up @@ -394,11 +392,6 @@ tomlkit==0.12.5
# pylint
tox==4.8.0
# via -r dev.in
typed-ast==1.5.5
# via
# -r typing.txt
# astroid
# mypy
types-boto==2.49.18.9
# via -r typing.txt
types-click==7.1.8
Expand All @@ -421,6 +414,8 @@ types-peewee==3.17.0.0
# via -r typing.txt
types-pillow==10.1.0.2
# via -r typing.txt
types-shapely==2.0.0.20240714
# via -r typing.txt
types-sqlalchemy==1.4.53.38
# via
# -r typing.txt
Expand All @@ -429,17 +424,14 @@ types-werkzeug==1.0.9
# via
# -r typing.txt
# types-flask
types-wtforms==3.1.0.2
# via -r typing.txt
typing-extensions==4.7.1
# via
# -r docs.txt
# -r typing.txt
# astroid
# importlib-metadata
# mypy
# platformdirs
# pylint
# pyright
# tox
urllib3==2.0.7
# via
# -r docs.txt
Expand Down
8 changes: 2 additions & 6 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.7
# This file is autogenerated by pip-compile with Python 3.8
# by the following command:
#
# pip-compile docs.in
Expand All @@ -21,9 +21,7 @@ idna==3.7
imagesize==1.4.1
# via sphinx
importlib-metadata==6.7.0
# via
# pallets-sphinx-themes
# sphinx
# via sphinx
jinja2==3.0.0
# via
# -c tests.in
Expand Down Expand Up @@ -65,8 +63,6 @@ sphinxcontrib-qthelp==1.0.3
# via sphinx
sphinxcontrib-serializinghtml==1.1.5
# via sphinx
typing-extensions==4.7.1
# via importlib-metadata
urllib3==2.0.7
# via requests
zipp==3.15.0
Expand Down
4 changes: 2 additions & 2 deletions requirements/tests.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ jinja2<=3.0.0
Flask-SQLAlchemy<3.0.0
peewee
wtf-peewee
mongoengine<=0.21.0
mongoengine
pymongo>=3.7.0
flask-mongoengine==0.8.2
pillow>=3.3.2
Babel<=2.9.1
flask-babelex
shapely>=1.8,<2
shapely>=2
geoalchemy2
psycopg2
pytest
Expand Down
Loading

0 comments on commit 5a75ad3

Please sign in to comment.