diff --git a/CHANGES.rst b/CHANGES.rst
index b7790133..8ab04d9d 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -2,7 +2,8 @@ Version 0.7.0
------------------
Added
-- Use msgpack for serialization, along with ``SESSION_SERIALIZATION_FORMAT`` to choose between ``json`` and ``msgpack``.
+~~~~~~~
+- Use msgpack for serialization, along with ``SESSION_SERIALIZATION_FORMAT`` to choose between ``'json'`` and ``'msgpack'``.
- Add time-to-live expiration for MongoDB.
- Add retry for SQL based storage.
- Add ``flask session_cleanup`` command and alternatively, ``SESSION_CLEANUP_N_REQUESTS`` for SQLAlchemy or future non-TTL backends.
@@ -10,12 +11,14 @@ Added
- Add logo and additional documentation.
Deprecated
-- Deprecated pickle. It is still available to read existing sessions, but will be removed in 1.0.0. All sessions will transfer to msgspec upon first interaction with 0.7.0.
+~~~~~~~~~~
+- Deprecated pickle. It is still available to read existing sessions, but will be removed in 1.0.0. All sessions will transfer to msgspec upon first interaction with 0.1.0.
- Remove null session in favour of specific exception messages.
- Deprecate ``SESSION_USE_SIGNER``.
-- Deprecate FileSystemSessionInterface in favor of the broader CacheLibSessionInterface.
+- Deprecate :class:`flask_session.filesystem.FileSystemSessionInterface` in favor of the broader :class:`flask_session.cachelib.CacheLibSessionInterface`.
Fixed
+~~~~~
- Prevent sid reuse on storage miss.
- Abstraction to improve consistency between backends.
- Enforce ``PERMANENT_SESSION_LIFETIME`` as expiration consistently for all backends.
@@ -28,7 +31,7 @@ Version 0.6.0
Released 2024-01-16
-- Use ``should_set_cookie`` for preventing each request from saving the session again.
+- Use :meth:`~ServerSideSession.should_set_cookie` for preventing each request from saving the session again.
- Permanent session otherwise empty will not be saved.
- Use `secrets` module to generate session identifiers, with 256 bits of
entropy (was previously 122).
diff --git a/docs/_static/icon/sequence.webp b/docs/_static/icon/sequence.webp
deleted file mode 100644
index 31cae2fd..00000000
Binary files a/docs/_static/icon/sequence.webp and /dev/null differ
diff --git a/docs/_static/sequence.webp b/docs/_static/sequence.webp
index 605838cb..bd0e3603 100644
Binary files a/docs/_static/sequence.webp and b/docs/_static/sequence.webp differ
diff --git a/docs/_static/styles.css b/docs/_static/styles.css
index 6387b469..3830d92f 100644
--- a/docs/_static/styles.css
+++ b/docs/_static/styles.css
@@ -3,3 +3,11 @@
.padded {
padding: 40px;
}
+
+table {
+ max-width: 680px;
+ width: -webkit-fill-available;
+ width: -moz-available;
+ width: fill-available;
+ width: stretch;
+}
\ No newline at end of file
diff --git a/docs/conf.py b/docs/conf.py
index 97d33db2..c9ed71da 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -14,6 +14,7 @@
"flask": ("http://flask.palletsprojects.com/", None),
"werkzeug": ("http://werkzeug.palletsprojects.com/", None),
"flask-sqlalchemy": ("http://flask-sqlalchemy.palletsprojects.com/", None),
+ "redis": ("http://redis-py.readthedocs.io/", None),
}
diff --git a/docs/config_cleanup.rst b/docs/config_cleanup.rst
index 1dcbf444..ac535f11 100644
--- a/docs/config_cleanup.rst
+++ b/docs/config_cleanup.rst
@@ -1,11 +1,11 @@
Scheduled session cleanup
-------------------------
-This is not required for the ``Redis``, ``Memecached``, ``Filesystem``, ``Mongodb`` storage engines, as they support time-to-live for keys.
-.. caution ::
+.. important ::
+
+ In the case of ``SQLAlchemy``, expired sessions are not automatically deleted from the database. You must use one of the following scheduled cleanup methods.
- In the case of the storage engines that do not support time-to-live (SQLAlchemy), expired sessions are not automatically deleted from the database. You must use one of the following scheduled cleanup methods.
Run the the following command regularly with a cron job or scheduler such as Heroku Scheduler to clean up expired sessions. This is the recommended way to clean up expired sessions.
@@ -13,4 +13,6 @@ Run the the following command regularly with a cron job or scheduler such as Her
flask session_cleanup
-Alternatively, set the configuration variable `SESSION_CLEANUP_N_REQUESTS` to the average number of requests after which the cleanup should be performed. This is less desirable than using the scheduled app command cleanup as it may slow down some requests but may be useful for small applications or rapid development.
+Alternatively, set the configuration variable ``SESSION_CLEANUP_N_REQUESTS`` to the average number of requests after which the cleanup should be performed. This is less desirable than using the scheduled app command cleanup as it may slow down some requests but may be useful for small applications or rapid development.
+
+This is not required for the ``Redis``, ``Memecached``, ``Filesystem``, ``Mongodb`` storage engines, as they support time-to-live for records.
\ No newline at end of file
diff --git a/docs/config_example.rst b/docs/config_example.rst
index 184f37c5..4f34101e 100644
--- a/docs/config_example.rst
+++ b/docs/config_example.rst
@@ -9,15 +9,13 @@ Here is an example of how to configure a redis backend:
app.config['SESSION_REDIS'] = Redis.from_url('redis://127.0.0.1:6379')
We are not supplying something like ``SESSION_REDIS_HOST`` and
-``SESSION_REDIS_PORT``, if you want to use the ``RedisSessionInterface``,
-you should configure ``SESSION_REDIS`` to your own ``redis.Redis`` instance.
-This gives you more flexibility, such as using the same
-``redis.Redis`` instance for cache purposes too, then you do not need to keep
-two ``redis.Redis`` instance in the same process.
+``SESSION_REDIS_PORT``, instead you should configure ``SESSION_REDIS`` to your own :meth:`redis.Redis` instance.
+This gives you more flexibility, such as using the same instance for cache purposes too, then you do not need to keep
+two instances in the same process.
If you do not set ``SESSION_REDIS``, Flask-Session will assume you are developing locally and create a
-``redis.Redis`` instance for you. It is expected you supply an instance of
-``redis.Redis`` in production.
+:meth:`redis.Redis` instance for you. It is expected you supply an instance of
+:meth:`redis.Redis` in production.
.. note::
diff --git a/docs/config_exceptions.rst b/docs/config_exceptions.rst
index fd8cde73..e192eba3 100644
--- a/docs/config_exceptions.rst
+++ b/docs/config_exceptions.rst
@@ -3,7 +3,7 @@ Retries
Only for SQL based storage, upon an exception, Flask-Session will retry with backoff up to 3 times. If the operation still fails after 3 retries, the exception will be raised.
-For other storage types, the retry logic is either included or can be configured in the client setup. Refer to the client's documentation for more information.
+For other storage types, the retry logic is either included or can be configured in the client setup. Refer to the relevant client documentation for more information.
Redis example with retries on certain errors:
diff --git a/docs/config_flask.rst b/docs/config_flask.rst
index efd1fc53..e8196d2c 100644
--- a/docs/config_flask.rst
+++ b/docs/config_flask.rst
@@ -21,10 +21,10 @@ modify them at runtime.
`SESSION_COOKIE_SAMESITE`_
-`PERMANENT_SESSION_LIFETIME`_
-
`SESSION_REFRESH_EACH_REQUEST`_
+`PERMANENT_SESSION_LIFETIME`_
+
.. _SESSION_COOKIE_NAME: https://flask.palletsprojects.com/en/latest/config/#SESSION_COOKIE_NAME
.. _SESSION_COOKIE_DOMAIN: https://flask.palletsprojects.com/en/latest/config/#SESSION_COOKIE_DOMAIN
.. _SESSION_COOKIE_PATH: https://flask.palletsprojects.com/en/latest/config/#SESSION_COOKIE_PATH
diff --git a/docs/config_flask_session.rst b/docs/config_flask_session.rst
index 2cb6e426..739fa49a 100644
--- a/docs/config_flask_session.rst
+++ b/docs/config_flask_session.rst
@@ -30,6 +30,8 @@ These are specific to Flask-Session.
Default: ``False``
+ .. deprecated:: 0.7.0
+
.. py:data:: SESSION_KEY_PREFIX
A prefix that is added before all session keys. This makes it easier to use the same backend storage server for different apps.
@@ -42,14 +44,21 @@ These are specific to Flask-Session.
Default: ``32``
+ .. versionadded:: 0.6.0
+
.. py:data:: SESSION_SERIALIZATION_FORMAT
- The serialization format to use. Can be 'msgpack' or 'json'. Set to 'msgpack' for a more efficient serialization format. Set to 'json' for a human-readable format.
+ The serialization format to use. Can be `'msgpack'`` or `'json'`. Set to `'msgpack'`` for a more efficient serialization format. Set to `'json'`` for a human-readable format.
Default: ``'msgpack'``
+ .. versionadded:: 0.7.0
+
+.. deprecated:: 0.7.0
+ ``SESSION_USE_SIGNER``
+
.. versionadded:: 0.7.0
``SESSION_SERIALIZATION_FORMAT``
-.. versionadded:: 0.6
+.. versionadded:: 0.6.0
``SESSION_ID_LENGTH``
diff --git a/docs/config_nonpermanent.rst b/docs/config_nonpermanent.rst
index a40f5866..695e93b6 100644
--- a/docs/config_nonpermanent.rst
+++ b/docs/config_nonpermanent.rst
@@ -1,7 +1,7 @@
Non-permanent session configuration
------------------------------------
-.. warning::
+.. caution::
Flask-session is primarily designed to be used with permanent sessions. If you want to use non-permanent sessions, you must set ``SESSION_PERMANENT=False`` and be aware of significant limitations.
diff --git a/docs/config_security.rst b/docs/config_security.rst
index 4ef4dd26..3e4a094a 100644
--- a/docs/config_security.rst
+++ b/docs/config_security.rst
@@ -2,16 +2,12 @@
Security configuration
----------------------
-.. caution::
+.. warning::
Flask is a micro-framework and does not provide all security features out of the box. It is important to configure security settings for your application.
Please refer to documentation for `Flask`_, `OWASP`_, and other resources such as `MDN`_ for the latest information on best practice.
-.. _Flask: https://flask.palletsprojects.com/en/2.3.x/security/#set-cookie-options
-.. _MDN: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies
-.. _OWASP: https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html
-
Consider the following Flask configurations in production:
.. list-table::
@@ -26,4 +22,10 @@ Consider the following Flask configurations in production:
* - SESSION_COOKIE_SAMESITE
- Use ``Lax`` or ``Strict``
-You can use a security plugin such as ``Flask-Talisman`` to set these and more.
\ No newline at end of file
+You can use a security plugin such as `Flask-Talisman`_ to set these and more.
+
+
+.. _Flask: https://flask.palletsprojects.com/en/2.3.x/security/#set-cookie-options
+.. _MDN: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies
+.. _OWASP: https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html
+.. _Flask-Talisman: https://github.com/wntrblm/flask-talisman
\ No newline at end of file
diff --git a/docs/config_storage.rst b/docs/config_storage.rst
index c61c8b34..50e2314d 100644
--- a/docs/config_storage.rst
+++ b/docs/config_storage.rst
@@ -31,26 +31,29 @@ FileSystem
Default: ``flask_session`` directory under current working directory.
+ .. deprecated:: 0.7.0
+
.. py:data:: SESSION_FILE_THRESHOLD
The maximum number of items the session stores before it starts deleting some.
Default: ``500``
+ .. deprecated:: 0.7.0
+
.. py:data:: SESSION_FILE_MODE
The file mode wanted for the session files.
Default: ``0600``
-.. deprecated:: 0.7.0
- ``SESSION_FILE_MODE``, ``SESSION_FILE_THRESHOLD`` and ``SESSION_FILE_DIR``. Use ``SESSION_CACHELIB`` instead.
+ .. deprecated:: 0.7.0
-Cachelib
+CacheLib
~~~~~~~~~~~~~~~~~~~~~~~
.. py:data:: SESSION_CACHELIB
- Any valid `cachelib backend `_. This allows you maximum flexibility in choosing the cache backend and its configuration.
+ Any valid `cachelib backend `_. This allows you maximum flexibility in choosing the cache backend and it's configuration.
The following would set a cache directory called "flask_session" and a threshold of 500 items before it starts deleting some.
@@ -58,6 +61,10 @@ Cachelib
app.config['SESSION_CACHELIB'] = FileSystemCache(cache_dir='flask_session', threshold=500)
+ .. important::
+
+ A ``default_timeout`` set in any of the ``CacheLib`` backends will be overrode by the ``PERMANENT_SESSION_LIFETIME`` when each stored session's expiry is set.
+
Default: ``FileSystemCache`` in ``./flask_session`` directory.
MongoDB
@@ -123,8 +130,12 @@ SqlAlchemy
Default: ``None``
+.. deprecated:: 0.7.0
+
+ ``SESSION_FILE_DIR``, ``SESSION_FILE_THRESHOLD``, ``SESSION_FILE_MODE``. Use ``SESSION_CACHELIB`` instead.
+
.. versionadded:: 0.7.0
``SESSION_CLEANUP_N_REQUESTS``
-.. versionadded:: 0.6
+.. versionadded:: 0.6.0
``SESSION_SQLALCHEMY_BIND_KEY``, ``SESSION_SQLALCHEMY_SCHEMA``, ``SESSION_SQLALCHEMY_SEQUENCE``
diff --git a/docs/installation.rst b/docs/installation.rst
index 986a23d7..bcdb42d6 100644
--- a/docs/installation.rst
+++ b/docs/installation.rst
@@ -10,11 +10,7 @@ Install from PyPI using an installer such as pip:
Flask-Session's only required dependency is msgspec for serialization, which has no sub-dependencies.
-.. note::
-
- You need to choose a storage type and install an appropriate client library.
-
-For example, if you want to use Redis as your storage, you will need to install the redis-py client library:
+You need to choose a storage type and install an appropriate client library so the app can communicate with storage. For example, if you want to use Redis as your storage, you will need to install the redis-py client library:
.. code-block:: bash
@@ -22,40 +18,36 @@ For example, if you want to use Redis as your storage, you will need to install
Redis is the recommended storage type for Flask-Session, as it has the most complete support for the features of Flask-Session with minimal configuration.
-Support
---------
+Direct support
+---------------
-Directly supported storage and client libraries:
+Flask-Session has an increasing number of directly supported storage and client libraries.
.. list-table::
:header-rows: 1
+ :align: left
* - Storage
- Client Library
* - Redis
- redis-py_
* - Memcached
- - pylibmc_, python-memcached_ or pymemcache_
+ - pylibmc_, python-memcached_, libmc_ or pymemcache_
* - MongoDB
- pymongo_
* - SQL Alchemy
- flask-sqlalchemy_
-Other clients may work if they use the same commands as the ones listed above.
+Other libraries may work if they use the same commands as the ones listed above.
Cachelib
--------
-Flask-Session also indirectly supports storage and client libraries via cachelib_, which is a wrapper around various cache libraries and subject to change. You must also install cachelib_ itself to use these.
-
-.. warning::
-
- As of writing, cachelib_ still use pickle_ as the default serializer, which may have security implications.
-
-Using cachlib :class:`FileSystemCache`` or :class:`SimpleCache` may be useful for development.
+Flask-Session also indirectly supports storage and client libraries via cachelib_, which is a wrapper around various cache libraries. You must also install cachelib_ itself to use these.
.. list-table::
:header-rows: 1
+ :align: left
* - Storage
- Client Library
@@ -75,6 +67,10 @@ Using cachlib :class:`FileSystemCache`` or :class:`SimpleCache` may be useful fo
- boto3_
+.. warning::
+
+ As of writing, cachelib_ still uses pickle_ as the default serializer, which may have security implications in production.
+
.. _redis-py: https://github.com/andymccurdy/redis-py
.. _pylibmc: http://sendapatch.se/projects/pylibmc/
diff --git a/docs/introduction.rst b/docs/introduction.rst
index 6094aa60..2590bf39 100644
--- a/docs/introduction.rst
+++ b/docs/introduction.rst
@@ -14,11 +14,11 @@ This is done by placing it in a cookie that is sent to and from the client on ea
This can be any small, basic information about that client or their interactions for quick retrieval (up to 4kB).
Server-side sessions differ by storing session data in server-side storage.
-A cookie is also used but it only contains the session identifier that links the client to their corresponding data on the server.
+A cookie is also used, but it only contains the session identifier that links the client to their corresponding data on the server.
-.. note::
- There are no individual session size limitations on server-side sessions,
- but developers should be cautious about abusing them for data which would be more suited for actual database storage.
+.. tip::
+ There are generally (some exceptions) no individual session size limitations for server-side sessions,
+ but developers should be cautious about abusing this for amounts or types data that would be more suited for actual database storage.
Flask-Session sequence diagram
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/docs/usage.rst b/docs/usage.rst
index 66bb7ba2..11a527c2 100644
--- a/docs/usage.rst
+++ b/docs/usage.rst
@@ -7,15 +7,9 @@ Quickstart
.. currentmodule:: flask_session
-Create your Flask application, load the configuration of choice, and
+Create your :class:`~flask.Flask` application, load the configuration of choice, and
then create the :class:`Session` object by passing it the application.
-.. note::
-
- You can not use ``Session`` instance directly, what ``Session`` does
- is just change the :attr:`~flask.Flask.session_interface` attribute on
- your Flask applications. You should always use :class:`flask.session` when accessing the current session.
-
.. code-block:: python
from flask import Flask, session
@@ -38,24 +32,30 @@ then create the :class:`Session` object by passing it the application.
This would automatically setup a redis client connected to `localhost:6379` and use it to store the session data.
-See the `configuration section `_ for more details.
+.. note::
+
+ You can not use :class:`~Session` instance directly, what :class:`~Session` does
+ is just change the :attr:`~flask.Flask.session_interface` attribute on
+ your Flask applications. You should always use :class:`flask.session` when accessing or modifying the current session.
+
+See the configuration section for more details.
Alternative initialization
---------------------------
-Rather than calling `Session(app)`, you may initialize later using :meth:`~Session.init_app`.
+Rather than calling :class:`~Session`, you may initialize later using :meth:`~Session.init_app`.
.. code-block:: python
sess = Session()
sess.init_app(app)
-Or, if you prefer to directly set parameters rather than using the configuration constants, you can initialize by setting the interface constructor directly to the :attr:`session_interface`.
+Or, if you prefer to directly set parameters rather than using the configuration constants, you can initialize by setting an instance of :class:`flask_session.redis.RedisSessionInterface` directly to the :attr:`flask.Flask.session_interface`.
.. code-block:: python
- from flask_session.implementations.redis import RedisSessionInterface
-
+ from flask_session.redis import RedisSessionInterface
+ from redis import Redis
...
redis = Redis(
diff --git a/src/flask_session/cachelib/__init__.py b/src/flask_session/cachelib/__init__.py
index 959c5d5d..e69de29b 100644
--- a/src/flask_session/cachelib/__init__.py
+++ b/src/flask_session/cachelib/__init__.py
@@ -1 +0,0 @@
-from .cachelib import CacheLibSessionInterface, CacheLibSession
diff --git a/src/flask_session/cachelib/cachelib.py b/src/flask_session/cachelib/cachelib.py
index 62335391..ad007d8e 100644
--- a/src/flask_session/cachelib/cachelib.py
+++ b/src/flask_session/cachelib/cachelib.py
@@ -1,12 +1,11 @@
from datetime import timedelta as TimeDelta
from typing import Optional
-from flask import Flask
+from cachelib.file import FileSystemCache
+
from .._utils import total_seconds
-from ..defaults import Defaults
from ..base import ServerSideSession, ServerSideSessionInterface
-from cachelib.file import FileSystemCache
-import warnings
+from ..defaults import Defaults
class CacheLibSession(ServerSideSession):
diff --git a/src/flask_session/filesystem/__init__.py b/src/flask_session/filesystem/__init__.py
index 79792687..e69de29b 100644
--- a/src/flask_session/filesystem/__init__.py
+++ b/src/flask_session/filesystem/__init__.py
@@ -1 +0,0 @@
-from .filesystem import FileSystemSessionInterface, FileSystemSession
diff --git a/src/flask_session/filesystem/filesystem.py b/src/flask_session/filesystem/filesystem.py
index 6cf1b392..919bb23f 100644
--- a/src/flask_session/filesystem/filesystem.py
+++ b/src/flask_session/filesystem/filesystem.py
@@ -1,12 +1,12 @@
+import warnings
from datetime import timedelta as TimeDelta
from typing import Optional
-from flask import Flask
+from cachelib.file import FileSystemCache
+
from .._utils import total_seconds
-from ..defaults import Defaults
from ..base import ServerSideSession, ServerSideSessionInterface
-from cachelib.file import FileSystemCache
-import warnings
+from ..defaults import Defaults
class FileSystemSession(ServerSideSession):
diff --git a/src/flask_session/memcached/__init__.py b/src/flask_session/memcached/__init__.py
index 9ca54ee1..e69de29b 100644
--- a/src/flask_session/memcached/__init__.py
+++ b/src/flask_session/memcached/__init__.py
@@ -1 +0,0 @@
-from .memcached import MemcachedSessionInterface, MemcachedSession
diff --git a/src/flask_session/memcached/memcached.py b/src/flask_session/memcached/memcached.py
index edbf0b63..0d12751e 100644
--- a/src/flask_session/memcached/memcached.py
+++ b/src/flask_session/memcached/memcached.py
@@ -1,13 +1,10 @@
+import time
from datetime import timedelta as TimeDelta
-from typing import Any, Optional
+from typing import Any, Optional, Protocol
-import msgspec
-import time
-from flask import Flask
from .._utils import total_seconds
-from ..defaults import Defaults
from ..base import ServerSideSession, ServerSideSessionInterface
-from typing import Protocol, Optional, Any
+from ..defaults import Defaults
class MemcacheClientProtocol(Protocol):
diff --git a/src/flask_session/mongodb/__init__.py b/src/flask_session/mongodb/__init__.py
index 1a003df7..e69de29b 100644
--- a/src/flask_session/mongodb/__init__.py
+++ b/src/flask_session/mongodb/__init__.py
@@ -1 +0,0 @@
-from .mongodb import MongoDBSessionInterface, MongoDBSession
diff --git a/src/flask_session/mongodb/mongodb.py b/src/flask_session/mongodb/mongodb.py
index 52dfddcf..cd5c37f8 100644
--- a/src/flask_session/mongodb/mongodb.py
+++ b/src/flask_session/mongodb/mongodb.py
@@ -1,15 +1,13 @@
from datetime import datetime
from datetime import timedelta as TimeDelta
-from typing import Any, Optional
+from typing import Optional
-import msgspec
-from flask import Flask
from itsdangerous import want_bytes
-from ..defaults import Defaults
-from ..base import ServerSideSession, ServerSideSessionInterface
-
from pymongo import MongoClient, version
+from ..base import ServerSideSession, ServerSideSessionInterface
+from ..defaults import Defaults
+
class MongoDBSession(ServerSideSession):
pass
diff --git a/src/flask_session/redis/__init__.py b/src/flask_session/redis/__init__.py
index 8c9f2a9e..e69de29b 100644
--- a/src/flask_session/redis/__init__.py
+++ b/src/flask_session/redis/__init__.py
@@ -1 +0,0 @@
-from .redis import RedisSessionInterface, RedisSession
diff --git a/src/flask_session/redis/redis.py b/src/flask_session/redis/redis.py
index 9833fded..54961550 100644
--- a/src/flask_session/redis/redis.py
+++ b/src/flask_session/redis/redis.py
@@ -1,13 +1,11 @@
from datetime import timedelta as TimeDelta
-from typing import Any, Optional
+from typing import Optional
-import msgspec
+from redis import Redis
-from flask import Flask
from .._utils import total_seconds
-from ..defaults import Defaults
from ..base import ServerSideSession, ServerSideSessionInterface
-from redis import Redis
+from ..defaults import Defaults
class RedisSession(ServerSideSession):
diff --git a/src/flask_session/sqlalchemy/__init__.py b/src/flask_session/sqlalchemy/__init__.py
index 2344d3a6..e69de29b 100644
--- a/src/flask_session/sqlalchemy/__init__.py
+++ b/src/flask_session/sqlalchemy/__init__.py
@@ -1 +0,0 @@
-from .sqlalchemy import SqlAlchemySessionInterface, SqlAlchemySession
diff --git a/src/flask_session/sqlalchemy/sqlalchemy.py b/src/flask_session/sqlalchemy/sqlalchemy.py
index 95888e66..1ae2783d 100644
--- a/src/flask_session/sqlalchemy/sqlalchemy.py
+++ b/src/flask_session/sqlalchemy/sqlalchemy.py
@@ -2,15 +2,14 @@
from datetime import timedelta as TimeDelta
from typing import Any, Optional
-import msgspec
from flask import Flask
+from flask_sqlalchemy import SQLAlchemy
from itsdangerous import want_bytes
+from sqlalchemy import Column, DateTime, Integer, LargeBinary, Sequence, String
from .._utils import retry_query
-from ..defaults import Defaults
from ..base import ServerSideSession, ServerSideSessionInterface
-from flask_sqlalchemy import SQLAlchemy
-from sqlalchemy import Column, String, LargeBinary, DateTime, Integer, Sequence
+from ..defaults import Defaults
class SqlAlchemySession(ServerSideSession):
diff --git a/tests/test_cachelib.py b/tests/test_cachelib.py
index 0de0df29..656a5c9e 100644
--- a/tests/test_cachelib.py
+++ b/tests/test_cachelib.py
@@ -1,4 +1,3 @@
-import tempfile
import flask
from flask_session.cachelib import CacheLibSession
diff --git a/tests/test_memcached.py b/tests/test_memcached.py
index acd734c4..0c455375 100644
--- a/tests/test_memcached.py
+++ b/tests/test_memcached.py
@@ -2,7 +2,6 @@
from contextlib import contextmanager
import flask
-import flask_session
import memcache # Import the memcache library
from flask_session.memcached import MemcachedSession
diff --git a/tests/test_mongodb.py b/tests/test_mongodb.py
index 12a57a21..0e3638be 100644
--- a/tests/test_mongodb.py
+++ b/tests/test_mongodb.py
@@ -2,9 +2,9 @@
from contextlib import contextmanager
import flask
+from flask_session.mongodb import MongoDBSession
from itsdangerous import want_bytes
from pymongo import MongoClient
-from flask_session.mongodb import MongoDBSession
class TestMongoSession: