Skip to content

Commit aa5edf5

Browse files
authored
Merge pull request #2495 from oefe/progress-wrap_file-add-mode
Fix missing `mode` property on file wrapper
2 parents 1f3ec9a + b51a303 commit aa5edf5

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919

2020
- Handle stdout/stderr being null https://github.com/Textualize/rich/pull/2513
2121
- Fix NO_COLOR support on legacy Windows https://github.com/Textualize/rich/pull/2458
22+
- Fix missing `mode` property on file wrapper breaking uploads via `requests` https://github.com/Textualize/rich/pull/2495
2223

2324
## [12.5.2] - 2022-07-18
2425

CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ The following people have contributed to the development of Rich:
2828
- [Paul McGuire](https://github.com/ptmcg)
2929
- [Antony Milne](https://github.com/AntonyMilneQB)
3030
- [Michael Milton](https://github.com/multimeric)
31+
- [Martina Oefelein](https://github.com/oefe)
3132
- [Nathan Page](https://github.com/nathanrpage97)
3233
- [Avi Perl](https://github.com/avi-perl)
3334
- [Laurent Peuch](https://github.com/psycojoker)

rich/progress.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ def fileno(self) -> int:
216216
def isatty(self) -> bool:
217217
return self.handle.isatty()
218218

219+
@property
220+
def mode(self) -> str:
221+
return self.handle.mode
222+
219223
@property
220224
def name(self) -> str:
221225
return self.handle.name

tests/test_progress.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ def test_wrap_file() -> None:
614614
with open(filename, "rb") as file:
615615
with rich.progress.wrap_file(file, total=total) as f:
616616
assert f.read() == b"Hello, World!"
617+
assert f.mode == "rb"
617618
assert f.name == filename
618619
assert f.closed
619620
assert not f.handle.closed

0 commit comments

Comments
 (0)