-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore/fix: re-enable linting for backend #2041
Open
akx
wants to merge
8
commits into
open-webui:dev
Choose a base branch
from
akx:lint-backend
base: dev
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
akx
force-pushed
the
lint-backend
branch
4 times, most recently
from
May 8, 2024 09:41
2398d65
to
3fddd6c
Compare
@tjbck Rebased once more on |
@tjbck have we reached a decision on this? |
8 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR re-enables linting for the backend (disabled 4 months ago in #368 because "too many issues") using Ruff, and fixes the issues it finds. Each commit should be fine to review in isolation, if this PR otherwise feels too large. Most of the cumulative diff is reordering imports.
I deliberately disabled some rules for the time being, though, with TODO notes that they really ought to be fixed; bare
try:except:
s for one are a bad habit, since they catch e.g.KeyboardInterrupt
s, so chances are the backend will ignore attempts of stopping it if the signal lands in a suitable place 😅Conversely, more rules could be added later.
It also switches formatting from
black
toruff
(they're 99.x% compatible, butruff
is a lot faster and formats some things in a neater way). The formatting actually found a couple of stray commas that inadvertently turned some logging statements into no-op 1-tuple constructions... 😄For CI, I made sure that the pinned versions from
requirements.txt
are used for Ruff – before this, CI could install a different version of Black than whatrequirements.txt
said.Testing
Since there is no test suite, all I really could do is test the app runs fine with these changes.
I ran under
coverage
(coverage run -m uvicorn main:app ...
), which gave me a coverage of about 49%.Dependencies
black
was dropped in favor ofruff
; technically, Ruff should be a development-time dependency only, but there is norequirements-dev.txt
or similar and Black was in the runtime deps, so I didn't change that.Changelog Entry
Changed