root: Upgrade Python syntax for version 3.11 using pyupgrade#7092
root: Upgrade Python syntax for version 3.11 using pyupgrade#7092PKizzle wants to merge 12 commits intogoauthentik:mainfrom
Conversation
✅ Deploy Preview for authentik-storybook canceled.
|
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #7092 +/- ##
==========================================
+ Coverage 90.27% 92.58% +2.30%
==========================================
Files 587 587
Lines 28898 28858 -40
==========================================
+ Hits 26088 26718 +630
+ Misses 2810 2140 -670
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
|
Shall I open a new PR with Edit: I tried upgrading to Python 3.12 but had issues installing the necessary pip packages (multidict does not want to build) |
|
@BeryJu I have updated the PR to incorporate the changes of #7096. Seems like the upgrade to Python 3.12 might take some time. Is there any reason not to merge this PR for version 3.11? What is missing in this PR is a way to automatically run pyupgrade but that shall be handled in another PR imho. |
|
|
✅ Deploy Preview for authentik ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
027e128 to
7c3ba64
Compare
Sometimes type hints using the new "| None" instead of using Optional fail.
In a way that future runs of pyupgrade will not cause problems
7c3ba64 to
b8f51d9
Compare
|
I think most of these changes were also made when we switched to ruff (#8498) which has pretty much the same policies and also allows disabling it for specific lines like the XML |
|
As mentioned in the comment above this has already been addressed by our change to ruff and also we're targeting python 3.12 now, so we'll close this. |

Result of running
pyupgrade --py311-plus `find ./authentik/ -name "*.py" -type f`as project uses Python 3.11Also, consider adding the pyupgrade command to the GitHub actions to automatically upgrade all new code.
Be aware that the developer is unwilling to allow ignoring certain source code lines so it may break certain functionality that requires workarounds.
In this case several manual adjustments were necessary as there are
typecollisions and the newElement | Nonetype hint instead ofOptional[Element]does not work reliably.More information can be found here: https://github.com/asottile/pyupgrade