Sourcery refactored master branch#1
Conversation
| for movie_title in movies: | ||
| movies_instances.append(Movie(movie_title)) | ||
|
|
||
| movies_instances.extend(Movie(movie_title) for movie_title in movies) |
There was a problem hiding this comment.
Function get_movies refactored with the following changes:
- Replace a for append loop with list extend (
for-append-to-extend)
| for movie_title in movies: | ||
| movies_instances.append(Movie(movie_title)) | ||
|
|
||
| movies_instances.extend(Movie(movie_title) for movie_title in movies) |
There was a problem hiding this comment.
Function get_movies refactored with the following changes:
- Replace a for append loop with list extend (
for-append-to-extend)
| for movie_title in movies: | ||
| movies_instances.append(Movie(movie_title)) | ||
|
|
||
| movies_instances.extend(Movie(movie_title) for movie_title in movies) |
There was a problem hiding this comment.
Function get_movies refactored with the following changes:
- Replace a for append loop with list extend (
for-append-to-extend)
| for movie_title in movies: | ||
| movies_instances.append(Movie(movie_title)) | ||
|
|
||
| movies_instances.extend(Movie(movie_title) for movie_title in movies) |
There was a problem hiding this comment.
Function get_movies refactored with the following changes:
- Replace a for append loop with list extend (
for-append-to-extend)
| movie = Movie(title=movie_title) | ||
| result = movie.add_to_movies() | ||
| if result: | ||
| if result := movie.add_to_movies(): |
There was a problem hiding this comment.
Function App.add_movie refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression)
| a = "J'ai une classe de " + str(30) + " élèves" | ||
| b = str(10) + " + " + "5" + " est égal à " + str(15) | ||
| a = f"J'ai une classe de {30} élèves" | ||
| b = f"{10} + 5 est égal à {15}" | ||
| c = 10 + int("5") | ||
| d = "L'addition de 10 + 5 est égal à " + str(10 + 5) No newline at end of file | ||
| d = f"L'addition de 10 + 5 est égal à {str(10 + 5)}" No newline at end of file |
There was a problem hiding this comment.
Lines 1-4 refactored with the following changes:
- Use f-string instead of string concatenation [×7] (
use-fstring-for-concatenation) - Remove unnecessary calls to
str()from formatted values in f-strings [×3] (remove-str-from-fstring)
| nombres_pairs = [] | ||
| for i in nombres: | ||
| if i % 2 == 0: | ||
| nombres_pairs.append(i) | ||
|
|
||
| nombres_pairs = [i for i in nombres if i % 2 == 0] | ||
| print(nombres_pairs) | ||
|
|
||
| # ---------------------------------------------------- # | ||
|
|
||
| nombres = range(-10, 10) | ||
| nombres_positifs = [] | ||
| for i in nombres: | ||
| if i >= 0: | ||
| nombres_positifs.append(i) | ||
|
|
||
| nombres_positifs = [i for i in nombres if i >= 0] | ||
| print(nombres_positifs) | ||
|
|
||
| # ---------------------------------------------------- # | ||
|
|
||
| nombres = range(5) | ||
| nombres_doubles = [] | ||
| for i in nombres: | ||
| nombres_doubles.append(i * 2) | ||
|
|
||
| nombres_doubles = [i * 2 for i in nombres] |
There was a problem hiding this comment.
Lines 2-25 refactored with the following changes:
- Convert for loop into list comprehension [×3] (
list-comprehension)
| return -1 | ||
| else: | ||
| return User.DB.insert(self.__dict__) | ||
| return -1 if self.exists() else User.DB.insert(self.__dict__) |
There was a problem hiding this comment.
Function User.save refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| return -1 | ||
| else: | ||
| return User.DB.insert(self.__dict__) | ||
| return -1 if self.exists() else User.DB.insert(self.__dict__) |
There was a problem hiding this comment.
Function User.save refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| return -1 | ||
| else: | ||
| return User.DB.insert(self.__dict__) | ||
| return -1 if self.exists() else User.DB.insert(self.__dict__) |
There was a problem hiding this comment.
Function User.save refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
Branch
masterrefactored 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
masterbranch, then run:Help us improve this pull request!