Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Sourcery Starbot ⭐ refactored wolph/python-progressbar#279

Closed
SourceryAI wants to merge 1 commit into
wolph:developwolph/python-progressbar:developfrom
SourceryAI:developSourceryAI/python-progressbar:developCopy head branch name to clipboard
Closed

Sourcery Starbot ⭐ refactored wolph/python-progressbar#279
SourceryAI wants to merge 1 commit into
wolph:developwolph/python-progressbar:developfrom
SourceryAI:developSourceryAI/python-progressbar:developCopy head branch name to clipboard

Conversation

@SourceryAI

Copy link
Copy Markdown

Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨

Here's your pull request refactoring your most popular Python repo.

If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.

Review changes via command line

To manually merge these changes, make sure you're on the develop branch, then run:

git fetch https://github.com/sourcery-ai-bot/python-progressbar develop
git merge --ff-only FETCH_HEAD
git reset HEAD^

@SourceryAI SourceryAI left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to GitHub API limits, only the first 60 comments can be shown.

Comment thread examples.py
@example
def shortcut_example():
for i in progressbar.progressbar(range(10)):
for _ in progressbar.progressbar(range(10)):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function shortcut_example refactored with the following changes:

Comment thread examples.py
@example
def prefixed_shortcut_example():
for i in progressbar.progressbar(range(10), prefix='Hi: '):
for _ in progressbar.progressbar(range(10), prefix='Hi: '):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function prefixed_shortcut_example refactored with the following changes:

Comment thread examples.py
@example
def templated_shortcut_example():
for i in progressbar.progressbar(range(10), suffix='{seconds_elapsed:.1}'):
for _ in progressbar.progressbar(range(10), suffix='{seconds_elapsed:.1}'):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function templated_shortcut_example refactored with the following changes:

Comment thread examples.py
Comment on lines -145 to +152
jobs = [
# Each job takes between 1 and 10 steps to complete
[0, random.randint(1, 10)]
for i in range(25) # 25 jobs total
]
jobs = [[0, random.randint(1, 10)] for _ in range(25)]

widgets = [
progressbar.Percentage(),
' ', progressbar.MultiProgressBar('jobs', fill_left=left),
]

max_value = sum([total for progress, total in jobs])
max_value = sum(total for progress, total in jobs)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function multi_progress_bar_example refactored with the following changes:

This removes the following comments ( why? ):

# Each job takes between 1 and 10 steps to complete
# 25 jobs total

Comment thread examples.py
Comment on lines -184 to +183
for i in progressbar.progressbar(list(range(100)), widgets=widgets):
for _ in progressbar.progressbar(list(range(100)), widgets=widgets):
time.sleep(0.03)

for i in progressbar.progressbar(iter(range(100)), widgets=widgets):
for _ in progressbar.progressbar(iter(range(100)), widgets=widgets):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function granular_progress_example refactored with the following changes:

Comment thread examples.py
Comment on lines -390 to +389
for i in bar((i for i in range(24))):
for _ in bar(iter(range(24))):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function animated_wheels refactored with the following changes:

Comment thread examples.py
Comment on lines -403 to +402
for i in bar((i for i in range(100))):
for _ in bar(iter(range(100))):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function format_label_bouncer refactored with the following changes:

Comment thread examples.py
Comment on lines -413 to +412
for i in bar((i for i in range(18))):
for _ in bar(iter(range(18))):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function format_label_rotating_bouncer refactored with the following changes:

Comment thread examples.py
Comment on lines -491 to +490
for i in range(10):
for _ in range(10):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function incrementing_bar refactored with the following changes:

Comment thread examples.py
Comment on lines -548 to +547
for i in range(100):
for _ in range(100):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function adaptive_eta_without_value_change refactored with the following changes:

Comment thread examples.py
Comment on lines -559 to +558
for n in bar(iter(range(100)), 100):
for _ in bar(iter(range(100)), 100):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function iterator_with_max_value refactored with the following changes:

Comment thread examples.py
Comment on lines -625 to +629
prefix='{variables.task} >> {variables.subtask}',
variables={'task': '--', 'subtask': '--'},
max_value=10 * num_subtasks) as bar:
prefix='{variables.task} >> {variables.subtask}',
variables={'task': '--', 'subtask': '--'},
max_value=10 * num_subtasks) as bar:
for tasks_name, subtasks in tasks.items():
for subtask_name in subtasks:
for i in range(10):
for _ in range(10):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function user_variables refactored with the following changes:

Comment thread examples.py
Comment on lines -659 to +658
for i in bar(range(200)):
for _ in bar(range(200)):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function simple_api_example refactored with the following changes:

Comment thread setup.py
if sys.argv[-1] == 'info':
for k, v in about.items():
print('%s: %s' % (k, v))
print(f'{k}: {v}')

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 19-19 refactored with the following changes:

Comment thread docs/conf.py
Comment thread progressbar/utils.py
'vt(10[02]|220|320)',
)
ANSI_TERM_RE = re.compile('^({})'.format('|'.join(ANSI_TERMS)), re.IGNORECASE)
ANSI_TERM_RE = re.compile(f"^({'|'.join(ANSI_TERMS)})", re.IGNORECASE)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 42-42 refactored with the following changes:

Comment thread progressbar/utils.py
def _flush(self) -> None:
value = self.buffer.getvalue()
if value:
if value := self.buffer.getvalue():

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function WrappingIO._flush refactored with the following changes:

Comment thread progressbar/utils.py
Comment on lines -441 to +458
if self.wrapped_stdout: # pragma: no branch
if isinstance(self.stdout, WrappingIO): # pragma: no branch
try:
self.stdout._flush()
except io.UnsupportedOperation: # pragma: no cover
self.wrapped_stdout = False
logger.warning(
'Disabling stdout redirection, %r is not seekable',
sys.stdout,
)

if self.wrapped_stderr: # pragma: no branch
if isinstance(self.stderr, WrappingIO): # pragma: no branch
try:
self.stderr._flush()
except io.UnsupportedOperation: # pragma: no cover
self.wrapped_stderr = False
logger.warning(
'Disabling stderr redirection, %r is not seekable',
sys.stderr,
)
if self.wrapped_stdout and isinstance(self.stdout, WrappingIO):
try:
self.stdout._flush()
except io.UnsupportedOperation: # pragma: no cover
self.wrapped_stdout = False
logger.warning(
'Disabling stdout redirection, %r is not seekable',
sys.stdout,
)

if self.wrapped_stderr and isinstance(self.stderr, WrappingIO):
try:
self.stderr._flush()
except io.UnsupportedOperation: # pragma: no cover
self.wrapped_stderr = False
logger.warning(
'Disabling stderr redirection, %r is not seekable',
sys.stderr,
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function StreamWrapper.flush refactored with the following changes:

This removes the following comments ( why? ):

# pragma: no branch

Comment thread progressbar/utils.py
Comment on lines -518 to +515
raise AttributeError("No such attribute: " + name)
raise AttributeError(f"No such attribute: {name}")

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AttributeDict.__getattr__ refactored with the following changes:

Comment thread progressbar/utils.py
Comment on lines -527 to +524
raise AttributeError("No such attribute: " + name)
raise AttributeError(f"No such attribute: {name}")

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AttributeDict.__delattr__ refactored with the following changes:

Comment thread progressbar/widgets.py
return format.format(**data)
else:
return format % data
return format.format(**data) if self.new_style else format % data

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function FormatWidgetMixin.__call__ refactored with the following changes:

Comment thread progressbar/widgets.py
Comment on lines -237 to +234
for key, value in self._fixed_colors.items():
if value is not None:
return True

return False
return any(value is not None for key, value in self._fixed_colors.items())

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function WidgetBase.uses_colors refactored with the following changes:

  • Use any() instead of for loop (use-any)

Comment thread progressbar/widgets.py
Comment on lines -335 to +328
if transform is None:
data[name] = data[key]
else:
data[name] = transform(data[key])
data[name] = data[key] if transform is None else transform(data[key])

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function FormatLabel.__call__ refactored with the following changes:

Comment thread progressbar/widgets.py
Comment on lines -404 to +394
return progress.extra.setdefault(self.key_prefix + 'sample_times', [])
return progress.extra.setdefault(f'{self.key_prefix}sample_times', [])

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SamplesMixin.get_sample_times refactored with the following changes:

Comment thread progressbar/widgets.py
Comment on lines -407 to +397
return progress.extra.setdefault(self.key_prefix + 'sample_values', [])
return progress.extra.setdefault(f'{self.key_prefix}sample_values', [])

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SamplesMixin.get_sample_values refactored with the following changes:

Comment on lines -106 to +110
for i in pbar(range(80)):
for _ in pbar(range(80)):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function example7 refactored with the following changes:

Comment on lines -112 to +116
for i in pbar((i for i in range(80))):
for _ in pbar(iter(range(80))):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function example8 refactored with the following changes:

Comment on lines -118 to +122
for i in pbar((i for i in range(50))):
for _ in pbar(iter(range(50))):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function example9 refactored with the following changes:

Comment on lines -125 to +129
for i in pbar((i for i in range(150))):
for _ in pbar(iter(range(150))):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function example10 refactored with the following changes:

Comment on lines -132 to +136
for i in pbar((i for i in range(150))):
for _ in pbar(iter(range(150))):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function example11 refactored with the following changes:

@wolph wolph closed this Apr 25, 2023
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.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.