X Tutup
Skip to content

Sourcery refactored master branch#1

Open
sourcery-ai[bot] wants to merge 1 commit intomasterfrom
sourcery/master
Open

Sourcery refactored master branch#1
sourcery-ai[bot] wants to merge 1 commit intomasterfrom
sourcery/master

Conversation

@sourcery-ai
Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot commented Jun 4, 2020

Branch master 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 master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Comment on lines -40 to +44
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))
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 __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):
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 rent_a_scooter refactored with the following changes:

  • Ensure constant in comparison is on the right
  • Simplify logical expression

Comment on lines -50 to +53
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
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 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()
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 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):
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 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):
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 rent_a_scooter refactored with the following changes:

  • Ensure constant in comparison is on the right
  • Simplify logical expression

Comment on lines -50 to +53
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
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 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()
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 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()):
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 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()):
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 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()):
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 DbSession.global_init refactored with the following changes:

  • Simplify logical expression

Comment on lines -6 to +8
__movie_data = dict()
__movie_data = {}
__genres = collections.defaultdict(list)
__top_movies = list()
__top_movies = []
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 6-8 refactored with the following changes:

  • Replace list() with []
  • Replace dict() with {}

return {}

d = dict(
return dict(
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 movie_to_dict refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -37 to +35
movie = __movie_data.get(imdb_code)
return movie
return __movie_data.get(imdb_code)
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 find_by_imdb refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -174 to +171
if not text or not text.strip():
if not (text and text.strip()):
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 __make_numerical refactored with the following changes:

  • Simplify logical expression

Comment on lines -6 to +8
__movie_data = dict()
__movie_data = {}
__genres = collections.defaultdict(list)
__top_movies = list()
__top_movies = []
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 6-8 refactored with the following changes:

  • Replace list() with []
  • Replace dict() with {}

return {}

d = dict(
return dict(
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 movie_to_dict refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -37 to +35
movie = __movie_data.get(imdb_code)
return movie
return __movie_data.get(imdb_code)
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 find_by_imdb refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -174 to +171
if not text or not text.strip():
if not (text and text.strip()):
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 __make_numerical refactored with the following changes:

  • Simplify logical expression

Comment on lines -198 to -204
parts = [
return [
p.strip()
for p in text.split('|')
if p and p.strip()
]

return parts
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 __split_separated_text refactored with the following changes:

  • Inline variable that is only used once

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.

1 participant

X Tutup