Skip to content

Use f-strings where possible#3984

Merged
abidlabs merged 5 commits into
gradio-app:mainfrom
akx:f-strings
Apr 27, 2023
Merged

Use f-strings where possible#3984
abidlabs merged 5 commits into
gradio-app:mainfrom
akx:f-strings

Conversation

@akx

@akx akx commented Apr 27, 2023

Copy link
Copy Markdown
Contributor

Description

  • Relevant motivation: f-strings are cleaner to read and generally more performant than concatenation or .format.
  • Summary of the change: wherever possible, use of .format etc. is replaced with f-strings. Initial automated conversion using ikamensh/flynt followed by manual fixes.

Checklist:

  • I have performed a self-review of my own code
  • I have added a short summary of my change to the CHANGELOG.md
  • My code follows the style guidelines of this project
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Semi-automated using ikamensh/flynt
@akx akx marked this pull request as ready for review April 27, 2023 08:51
@gradio-pr-bot

Copy link
Copy Markdown
Collaborator

All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-3984-all-demos

Comment thread gradio/interface.py Outdated
Comment thread gradio/utils.py Outdated
@abidlabs

Copy link
Copy Markdown
Member

Thanks so much for fixing these @akx! Just noticed a couple of issues, which I'll commit and then merge in this branch

@akx

akx commented Apr 27, 2023

Copy link
Copy Markdown
Contributor Author

Thanks so much for fixing these @akx! Just noticed a couple of issues, which I'll commit and then merge in this branch

You're welcome! Should probably enable Ruff UP032 to catch these in the future, but maybe that's after #3979 is merged (the full Ruff UP suite will also change type annotations to new-style ones, which should be fine since most of the codebase is from __future__ import annotations anyway... anyway, that's a separate future PR :) )

@abidlabs abidlabs merged commit d25226f into gradio-app:main Apr 27, 2023
akx added a commit to akx/gradio that referenced this pull request Apr 28, 2023
abidlabs added a commit that referenced this pull request Apr 28, 2023
* Update ruff to 0.0.263

* Get rid of bare except:s

* Fix two Ruff E731s by moving expand_{color,size} to the relevant classes

* Fix Ruff E731 and some variable shadowing in theme builder

* Fix remaining Ruff E731s

* Get rid of unused Ruff ignores

* Fix ruff B904 issues (raise from)

* Fix Ruff B007: loop-control variable not used

* Fix Ruff B011 (do not assert false)

* Remove unused args and kwargs from Progress.tqdm() (spotted via Ruff B026)

* Fix mutable argument default in CheckboxGroup

* Noqa ABC-related lint warnings for Interpretable

* Add missed assert in test_queueing (ruff B015)

* Enable ruff B

* Enable ruff C and fix issues

* Add changelog

* Add UP03[012] after #3984

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
@akx akx deleted the f-strings branch June 27, 2023 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants