Fix 'itsdangerous' import error when not using Authentication Backend #597
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
When importing
sqladmin.Admin
:...the application imports from
.authentication
:sqladmin/sqladmin/application.py
Line 34 in 724b9a9
Which in turn calls
starlette.middleware.sessions
:sqladmin/sqladmin/authentication.py
Line 6 in 724b9a9
And in starlette package,
middleware.session
tries to importitsdangerous
: https://github.com/encode/starlette/blob/cb6d284877cd359a21a0f31ebf8103a7b285a848/starlette/middleware/sessions.py#L5However, this package is not installed automatically: it's part of the "full" deps: https://github.com/encode/starlette/blob/cb6d284877cd359a21a0f31ebf8103a7b285a848/pyproject.toml#L37
Therefore, it's easily possible to install
![image](https://private-user-images.githubusercontent.com/9964605/264452014-ea827940-411c-4bd3-b0e8-7f5f0c3fef1d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyMjU4NzEsIm5iZiI6MTczOTIyNTU3MSwicGF0aCI6Ii85OTY0NjA1LzI2NDQ1MjAxNC1lYTgyNzk0MC00MTFjLTRiZDMtYjBlOC03ZjVmMGMzZmVmMWQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTBUMjIxMjUxWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YWQ1MGRmMTdlYzRkZGEyNzk2Mzg3ZmNjZWUzZTRjMTM5ZGQ3NWIxMGMzMWMzMjljNzI0NjcwZjk4MzMxZGVlNyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.gi-xIaD_KsHelfhH0AG9p2VuuF7byvhgi7qToMjVfvo)
sqladmin
and not this crucial sub-dependency, creating an error when trying to run the site:Solution
Either:
itsdangerous
as a named dependency here (which seems odd to name a sub-dependency just to alleviate this issue); orstarlette[full]
as a main dependency, ensuring all dependencies are covered up front.This PR is a simple change implementing the latter.