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
Ensure that stderr/stdout has flush attr before calling it (Sourcery refactored) #1249
base: master
Are you sure you want to change the base?
Conversation
2f43363
to
1ea74c3
Compare
Codecov Report
@@ Coverage Diff @@
## master #1249 +/- ##
==========================================
- Coverage 89.68% 87.24% -2.45%
==========================================
Files 26 26
Lines 1735 1732 -3
Branches 287 288 +1
==========================================
- Hits 1556 1511 -45
- Misses 133 165 +32
- Partials 46 56 +10 |
989e110
to
b28392f
Compare
eac8e7b
to
7b3c166
Compare
7b3c166
to
e4c2883
Compare
postfix = ', ' + postfix if postfix else '' | ||
postfix = f', {postfix}' if postfix else '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function tqdm.format_meter
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
# find unfixed (`pos >= 0`) overflow (`pos >= nrows - 1`) | ||
instances = list(filter( | ||
lambda i: hasattr(i, "pos") and last <= i.pos, | ||
cls._instances)) | ||
# set first found to current `pos` | ||
if instances: | ||
if instances := list( | ||
filter( | ||
lambda i: hasattr(i, "pos") and last <= i.pos, | ||
cls._instances, | ||
) | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function tqdm._decr_instances
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
This removes the following comments ( why? ):
# set first found to current `pos`
# find unfixed (`pos >= 0`) overflow (`pos >= nrows - 1`)
) or dynamic_ncols: # pragma: no cover | ||
): # pragma: no cover | ||
if dynamic_ncols: | ||
dynamic_ncols = _screen_shape_wrapper() | ||
if dynamic_ncols: | ||
ncols, nrows = dynamic_ncols(file) | ||
else: | ||
_dynamic_ncols = _screen_shape_wrapper() | ||
if _dynamic_ncols: | ||
_ncols, _nrows = _dynamic_ncols(file) | ||
if ncols is None: | ||
ncols = _ncols | ||
if nrows is None: | ||
nrows = _nrows | ||
|
||
elif _dynamic_ncols := _screen_shape_wrapper(): | ||
_ncols, _nrows = _dynamic_ncols(file) | ||
if ncols is None: | ||
ncols = _ncols | ||
if nrows is None: | ||
nrows = _nrows | ||
|
||
elif dynamic_ncols: # pragma: no cover | ||
dynamic_ncols = _screen_shape_wrapper() | ||
if dynamic_ncols: | ||
ncols, nrows = dynamic_ncols(file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function tqdm.__init__
refactored with the following changes:
- Split conditional into multiple branches (
split-or-ifs
) - Remove redundant conditional (
remove-redundant-if
) - Merge else clause's nested if statement into elif (
merge-else-if-into-elif
) - Use named expression to simplify assignment and conditional (
use-named-expression
)
This removes the following comments ( why? ):
# pragma: no cover
for obj in iterable: | ||
yield obj | ||
yield from iterable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function tqdm.__iter__
refactored with the following changes:
- Replace yield inside for loop with yield from (
yield-from
)
self.desc = desc + ': ' if desc else '' | ||
self.desc = f'{desc}: ' if desc else '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function tqdm.set_description
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self.postfix = ', '.join(key + '=' + postfix[key].strip() | ||
for key in postfix.keys()) | ||
self.postfix = ', '.join( | ||
f'{key}=' + postfix[key].strip() for key in postfix.keys() | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function tqdm.set_postfix
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
Sourcery Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 0.06%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
Pull Request #1248 refactored by Sourcery.
Since the original Pull Request was opened as a fork in a contributor's
repository, we are unable to create a Pull Request branching from it.
To incorporate these changes, you can either:
Merge this Pull Request instead of the original, or
Ask your contributor to locally incorporate these commits and push them to
the original Pull Request
Incorporate changes via command line
NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Help us improve this pull request!