Skip to content

Commit

Permalink
format() → f-string
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriPapadopoulos committed Nov 16, 2023
1 parent 2285c9f commit d291110
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ The following people have contributed to the development of Rich:
- [Michael Milton](https://github.com/multimeric)
- [Martina Oefelein](https://github.com/oefe)
- [Nathan Page](https://github.com/nathanrpage97)
- [Dimitri Papadopoulos Orfanos](https://github.com/DimitriPapadopoulos)
- [Dave Pearson](https://github.com/davep/)
- [Avi Perl](https://github.com/avi-perl)
- [Laurent Peuch](https://github.com/psycojoker)
Expand Down
2 changes: 1 addition & 1 deletion examples/print_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def print_calendar(year):

for week_day in cal.iterweekdays():
table.add_column(
"{:.3}".format(calendar.day_name[week_day]), justify="right"
f"{calendar.day_name[week_day]:.3}", justify="right"
)

month_days = cal.monthdayscalendar(year, month)
Expand Down
2 changes: 1 addition & 1 deletion rich/filesize.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def _to_str(
if size == 1:
return "1 byte"
elif size < base:
return "{:,} bytes".format(size)
return f"{size:,} bytes"

for i, suffix in enumerate(suffixes, 2): # noqa: B007
unit = base**i
Expand Down
2 changes: 1 addition & 1 deletion rich/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ def open(
# normalize the mode (always rb, rt)
_mode = "".join(sorted(mode, reverse=False))
if _mode not in ("br", "rt", "r"):
raise ValueError("invalid mode {!r}".format(mode))
raise ValueError(f"invalid mode {mode!r}")

# patch buffering to provide the same behaviour as the builtin `open`
line_buffering = buffering == 1
Expand Down

0 comments on commit d291110

Please sign in to comment.