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.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk2MjI0MjAsIm5iZiI6MTcxOTYyMjEyMCwicGF0aCI6Ii85OTY0NjA1LzI2NDQ1MjAxNC1lYTgyNzk0MC00MTFjLTRiZDMtYjBlOC03ZjVmMGMzZmVmMWQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYyOSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MjlUMDA0ODQwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MTg2ZDRkNTA1MzFmMjJhYmE3NDAzMTllYmE4MmE5MjFkNzMwYTI2YzBmMGYwNjJlZmQ1Y2M3YmRhMDhjMTAwOCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.ZIHjeFh7KKHf5RHfaM_PhDq43buxX_16OEDhdTUfMeo)
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.