Conversation
| for _ in range(0, COUNT): | ||
| for _ in range(COUNT): | ||
| s = Scooter() | ||
| s.model = random.choice(models) | ||
| s.battery_level = 100 | ||
| s.vin = ''.join((random.choice(vin_values) for _ in range(0, 18))) | ||
| s.vin = ''.join(random.choice(vin_values) for _ in range(18)) |
There was a problem hiding this comment.
Function __import_scooters refactored with the following changes:
- Replace range(0, x) with range(x)
| chose_it = try_int(input('Which one do you want? ')) - 1 | ||
|
|
||
| if not (0 <= chose_it or chose_it < len(scooters)): | ||
| if chose_it < 0 and chose_it >= len(scooters): |
There was a problem hiding this comment.
Function rent_a_scooter refactored with the following changes:
- Ensure constant in comparison is on the right
- Simplify logical expression
| if fallthrough is not None: | ||
| if self._falling_through: | ||
| self._func_stack.append(func) | ||
| if not fallthrough: | ||
| self._falling_through = False | ||
| if fallthrough is not None and self._falling_through: | ||
| self._func_stack.append(func) | ||
| if not fallthrough: | ||
| self._falling_through = False |
There was a problem hiding this comment.
Function switch.case refactored with the following changes:
- Merge nested if conditions
|
|
||
| # noinspection PyComparisonWithNone | ||
| scooters = session.query(Scooter).filter(Scooter.location_id == None).all() | ||
| scooters = session.query(Scooter).filter(Scooter.location_id is None).all() |
There was a problem hiding this comment.
Function rented_scooters refactored with the following changes:
- Use x is None rather than x == None
| chose_it = try_int(input('Which one do you want? ')) - 1 | ||
|
|
||
| if not (0 <= chose_it or chose_it < len(scooters)): | ||
| if chose_it < 0 and chose_it >= len(scooters): |
There was a problem hiding this comment.
Function rent_a_scooter refactored with the following changes:
- Ensure constant in comparison is on the right
- Simplify logical expression
| chose_it = try_int(input('Which one do you want? ')) - 1 | ||
|
|
||
| if not (0 <= chose_it or chose_it < len(scooters)): | ||
| if chose_it < 0 and chose_it >= len(scooters): |
There was a problem hiding this comment.
Function rent_a_scooter refactored with the following changes:
- Ensure constant in comparison is on the right
- Simplify logical expression
| if fallthrough is not None: | ||
| if self._falling_through: | ||
| self._func_stack.append(func) | ||
| if not fallthrough: | ||
| self._falling_through = False | ||
| if fallthrough is not None and self._falling_through: | ||
| self._func_stack.append(func) | ||
| if not fallthrough: | ||
| self._falling_through = False |
There was a problem hiding this comment.
Function switch.case refactored with the following changes:
- Merge nested if conditions
|
|
||
| # noinspection PyComparisonWithNone | ||
| scooters = session.query(Scooter).filter(Scooter.location_id == None).all() | ||
| scooters = session.query(Scooter).filter(Scooter.location_id is None).all() |
There was a problem hiding this comment.
Function rented_scooters refactored with the following changes:
- Use x is None rather than x == None
| return | ||
|
|
||
| if not db_file or not db_file.strip(): | ||
| if not (db_file and db_file.strip()): |
There was a problem hiding this comment.
Function DbSession.global_init refactored with the following changes:
- Simplify logical expression
| return | ||
|
|
||
| if not db_file or not db_file.strip(): | ||
| if not (db_file and db_file.strip()): |
There was a problem hiding this comment.
Function DbSession.global_init refactored with the following changes:
- Simplify logical expression
| return | ||
|
|
||
| if not db_file or not db_file.strip(): | ||
| if not (db_file and db_file.strip()): |
There was a problem hiding this comment.
Function DbSession.global_init refactored with the following changes:
- Simplify logical expression
| __movie_data = dict() | ||
| __movie_data = {} | ||
| __genres = collections.defaultdict(list) | ||
| __top_movies = list() | ||
| __top_movies = [] |
There was a problem hiding this comment.
Lines 6-8 refactored with the following changes:
- Replace list() with []
- Replace dict() with {}
| return {} | ||
|
|
||
| d = dict( | ||
| return dict( |
There was a problem hiding this comment.
Function movie_to_dict refactored with the following changes:
- Inline variable that is only used once
| movie = __movie_data.get(imdb_code) | ||
| return movie | ||
| return __movie_data.get(imdb_code) |
There was a problem hiding this comment.
Function find_by_imdb refactored with the following changes:
- Inline variable that is only used once
| if not text or not text.strip(): | ||
| if not (text and text.strip()): |
There was a problem hiding this comment.
Function __make_numerical refactored with the following changes:
- Simplify logical expression
| __movie_data = dict() | ||
| __movie_data = {} | ||
| __genres = collections.defaultdict(list) | ||
| __top_movies = list() | ||
| __top_movies = [] |
There was a problem hiding this comment.
Lines 6-8 refactored with the following changes:
- Replace list() with []
- Replace dict() with {}
| return {} | ||
|
|
||
| d = dict( | ||
| return dict( |
There was a problem hiding this comment.
Function movie_to_dict refactored with the following changes:
- Inline variable that is only used once
| movie = __movie_data.get(imdb_code) | ||
| return movie | ||
| return __movie_data.get(imdb_code) |
There was a problem hiding this comment.
Function find_by_imdb refactored with the following changes:
- Inline variable that is only used once
| if not text or not text.strip(): | ||
| if not (text and text.strip()): |
There was a problem hiding this comment.
Function __make_numerical refactored with the following changes:
- Simplify logical expression
| parts = [ | ||
| return [ | ||
| p.strip() | ||
| for p in text.split('|') | ||
| if p and p.strip() | ||
| ] | ||
|
|
||
| return parts |
There was a problem hiding this comment.
Function __split_separated_text refactored with the following changes:
- Inline variable that is only used once
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: