-
Notifications
You must be signed in to change notification settings - Fork 0
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
Sourcery refactored main branch #28
base: main
Are you sure you want to change the base?
Conversation
builder.add_from_file("{}/data/ffripper.glade".format(os.path.dirname(os.path.realpath(__file__)))) | ||
builder.add_from_file( | ||
f"{os.path.dirname(os.path.realpath(__file__))}/data/ffripper.glade" | ||
) | ||
|
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.
Lines 30-30
refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting
)
@@ -24,18 +24,20 @@ | |||
A fast, powerful and simple-to-use graphical CD ripper | |||
""" | |||
|
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.
Lines 34-38
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
) - Replace assignment and augmented assignment with single assignment (
merge-assign-and-aug-assign
)
for j in range(len(self.dict['disc']['release-list'][0]['medium-list'][i]['track-list'])): | ||
tracks.append( | ||
TrackInfo(self.dict['disc']['release-list'][0]['medium-list'][i]['track-list'][j] | ||
['recording']["title"], | ||
self.dict['disc']['release-list'][0]['medium-list'][i]['track-list'][j][ | ||
'length'], | ||
self.dict['disc']['release-list'][0]['date'], | ||
self.dict['disc']['release-list'][0]['medium-list'][i]['track-list'] | ||
[j]['recording']['artist-credit'][0]['artist']['name'])) | ||
tracks.extend( | ||
TrackInfo( | ||
self.dict['disc']['release-list'][0][ | ||
'medium-list' | ||
][i]['track-list'][j]['recording']["title"], | ||
self.dict['disc']['release-list'][0][ | ||
'medium-list' | ||
][i]['track-list'][j]['length'], | ||
self.dict['disc']['release-list'][0]['date'], | ||
self.dict['disc']['release-list'][0][ | ||
'medium-list' | ||
][i]['track-list'][j]['recording'][ | ||
'artist-credit' | ||
][ | ||
0 | ||
][ | ||
'artist' | ||
][ | ||
'name' | ||
], | ||
) | ||
for j in range( | ||
len( | ||
self.dict['disc']['release-list'][0][ | ||
'medium-list' | ||
][i]['track-list'] | ||
) | ||
) | ||
) | ||
|
||
except IndexError: | ||
for i in range(len(self.dict['disc']['release-list'][0]['medium-list'][0]['track-list'])): | ||
tracks.append( | ||
TrackInfo(self.dict['disc']['release-list'][0]['medium-list'][0]['track-list'][i]['recording'][ | ||
"title"], | ||
self.dict['disc']['release-list'][0]['medium-list'][0]['track-list'][i]['length'], | ||
self.dict['disc']['release-list'][0]['date'], None)) | ||
tracks.extend( | ||
TrackInfo( | ||
self.dict['disc']['release-list'][0]['medium-list'][0][ | ||
'track-list' | ||
][i]['recording']["title"], | ||
self.dict['disc']['release-list'][0]['medium-list'][0][ | ||
'track-list' | ||
][i]['length'], | ||
self.dict['disc']['release-list'][0]['date'], | ||
None, | ||
) | ||
for i in range( | ||
len( | ||
self.dict['disc']['release-list'][0]['medium-list'][0][ | ||
'track-list' | ||
] | ||
) | ||
) | ||
) | ||
|
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 CdDiscParser.parse_for_tracks
refactored with the following changes:
- Replace a for append loop with list extend [×2] (
for-append-to-extend
)
def bytes2png(data, output_dir, filename): # type: (bytes, str, str) -> str | ||
def bytes2png(data, output_dir, filename): # type: (bytes, str, str) -> str |
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 Image.bytes2png
refactored with the following changes:
- Use f-string instead of string concatenation [×4] (
use-fstring-for-concatenation
) - Replace call to format with f-string (
use-fstring-for-formatting
)
self._player.set_property("uri", "file://" + self.filepath) | ||
self._player.set_property("uri", f"file://{self.filepath}") |
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 Player.set_file
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
logger.debug("Current fraction: {}%".format(window.progressbar.get_fraction() * 100)) | ||
logger.debug("Fraction: {}".format(percentage)) | ||
logger.debug(f"Current fraction: {window.progressbar.get_fraction() * 100}%") | ||
logger.debug(f"Fraction: {percentage}") |
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 MyCopyListener.__main_thread_updater
refactored with the following changes:
- Replace call to format with f-string [×2] (
use-fstring-for-formatting
)
self.player.set_file(self.disc.mount_point + "/" + self.disc_tracks[0]) | ||
self.player.set_file(f"{self.disc.mount_point}/{self.disc_tracks[0]}") |
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 RipperWindow.set_player
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
logger.debug("Changed row: {}".format(row)) | ||
logger.debug(f"Changed row: {row}") | ||
self.player.reset() | ||
index = int(row.get_indices()[0]) | ||
self.player.set_file(self.disc.mount_point + "/" + self.disc_tracks[index]) | ||
self.player.set_file(f"{self.disc.mount_point}/{self.disc_tracks[index]}") |
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 RipperWindow.on_tree_view_columns_changed
refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting
) - Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
window = RipperWindow(builder, data + "settings.yaml") | ||
window = RipperWindow(builder, f"{data}settings.yaml") | ||
load = Loader() | ||
load.load_formats(formats) | ||
load.load_settings(data + "settings.yaml") | ||
load.load_settings(f"{data}settings.yaml") |
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 main
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
folder = None | ||
response = dialog.run() | ||
if response == Gtk.ResponseType.OK: | ||
folder = dialog.get_filename() | ||
folder = dialog.get_filename() if response == Gtk.ResponseType.OK else None |
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 UiObjects.chooser
refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block
) - Move setting of default value for variable into
else
branch (introduce-default-else
) - Replace if statement with if expression (
assign-if-exp
)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.13%.
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! |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Branch
main
refactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
main
branch, then run:Help us improve this pull request!