Skip to content

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Aug 30, 2023

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^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from gloc-mike August 30, 2023 02:39
Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

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 on lines -17 to -22
VALID_MANUFACTURERS = set([car["manufacturer"]
for car in cars.values()])
VALID_MANUFACTURERS = {car["manufacturer"] for car in cars.values()}
CAR_NOT_FOUND = 'Car not found'

# definition

Copy link
Author

Choose a reason for hiding this comment

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

Lines 17-22 refactored with the following changes:

This removes the following comments ( why? ):

# definition

"""Test to fail create_car's len(cars)+1 (fix max(cars.keys())+1)"""
car_count = len(cars)
response = client.delete(f'/99/')
response = client.delete('/99/')
Copy link
Author

Choose a reason for hiding this comment

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

Function test_create_car_after_delete refactored with the following changes:

from program import app

time_now = str(datetime.today())
time_now = str(datetime.now())
Copy link
Author

Choose a reason for hiding this comment

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

Lines 8-8 refactored with the following changes:

Comment on lines -46 to +48
r = requests.get('https://pokeapi.co/api/v2/pokemon-color/' + colour.lower())
r = requests.get(f'https://pokeapi.co/api/v2/pokemon-color/{colour.lower()}')
pokedata = r.json()
pokemon = []

for i in pokedata['pokemon_species']:
pokemon.append(i['name'])

return pokemon
return [i['name'] for i in pokedata['pokemon_species']]
Copy link
Author

Choose a reason for hiding this comment

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

Function get_poke_colours refactored with the following changes:

services.location_service.use_cached_data = True

print("Using cached data? {}".format(data.get('use_cached_data', False)))
print(f"Using cached data? {data.get('use_cached_data', False)}")
Copy link
Author

Choose a reason for hiding this comment

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

Function configure_app refactored with the following changes:

services.location_service.use_cached_data = True

print("Using cached data? {}".format(data.get('use_cached_data', False)))
print(f"Using cached data? {data.get('use_cached_data', False)}")
Copy link
Author

Choose a reason for hiding this comment

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

Function configure_app refactored with the following changes:

data = resp.json()

city_data = data.get(f'{zip_code}, {country}', dict())
city_data = data.get(f'{zip_code}, {country}', {})
Copy link
Author

Choose a reason for hiding this comment

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

Function get_lat_long refactored with the following changes:

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
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:

  • Simplify logical expression using De Morgan identities (de-morgan)
  • Ensure constant in comparison is on the right (flip-comparison)

return

conn_str = 'sqlite:///' + db_folder.get_full_path(db_name)
conn_str = f'sqlite:///{db_folder.get_full_path(db_name)}'
Copy link
Author

Choose a reason for hiding this comment

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

Function global_init refactored with the following changes:

self._falling_through = False

if isinstance(key, list) or isinstance(key, range):
if isinstance(key, (list, range)):
Copy link
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:

Comment on lines -88 to +90
raise Exception("Value does not match any case and there "
"is no default case: value {}".format(self.value))
raise Exception(
f"Value does not match any case and there is no default case: value {self.value}"
)
Copy link
Author

Choose a reason for hiding this comment

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

Function switch.__exit__ refactored with the following changes:


# 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
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:

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
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:

  • Simplify logical expression using De Morgan identities (de-morgan)
  • Ensure constant in comparison is on the right (flip-comparison)

Comment on lines -54 to +56
parked_scooters = []
# todo show parked scooters
print()
return parked_scooters
return []
Copy link
Author

Choose a reason for hiding this comment

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

Function find_available_scooters refactored with the following changes:

self._falling_through = False

if isinstance(key, list) or isinstance(key, range):
if isinstance(key, (list, range)):
Copy link
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:

Comment on lines -140 to +125
parts = [
p.strip()
for p in text.split('|')
if p and p.strip()
]

return parts
return [p.strip() for p in text.split('|') if p and p.strip()]
Copy link
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:

def search_by_keyword(_, resp: responder.Response, keyword: str):
movies = db.search_keyword(keyword)
print("Searching for movie by keyword: {}".format(keyword))
print(f"Searching for movie by keyword: {keyword}")
Copy link
Author

Choose a reason for hiding this comment

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

Function search_by_keyword refactored with the following changes:

def search_by_director(_, resp: responder.Response, director_name: str):
movies = db.search_director(director_name)
print("Searching for movie by director: {}".format(director_name))
print(f"Searching for movie by director: {director_name}")
Copy link
Author

Choose a reason for hiding this comment

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

Function search_by_director refactored with the following changes:


def __repr__(self):
return 'User {}'.format(self.username)
return f'User {self.username}'
Copy link
Author

Choose a reason for hiding this comment

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

Function User.__repr__ refactored with the following changes:

Comment on lines -23 to +25
user = User.query.filter_by(username=request.form.get('username')).first()
if user:
if user := User.query.filter_by(
username=request.form.get('username')
).first():
Copy link
Author

Choose a reason for hiding this comment

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

Function loginpage refactored with the following changes:

Comment on lines -57 to -58
if __name__ == '__main__':
pass
Copy link
Author

Choose a reason for hiding this comment

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

Lines 57-58 refactored with the following changes:

Comment on lines -28 to +29
conn_str = 'sqlite:///' + db_file
print("Connecting to DB at: {}".format(conn_str))
conn_str = f'sqlite:///{db_file}'
print(f"Connecting to DB at: {conn_str}")
Copy link
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:

repository.add_payment(amount, bill_id)

return HTTPFound(location='/bill/{}'.format(bill_id))
return HTTPFound(location=f'/bill/{bill_id}')
Copy link
Author

Choose a reason for hiding this comment

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

Function details_post refactored with the following changes:

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
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:

  • Simplify logical expression using De Morgan identities (de-morgan)
  • Ensure constant in comparison is on the right (flip-comparison)

return

conn_str = 'sqlite:///' + db_folder.get_full_path(db_name)
conn_str = f'sqlite:///{db_folder.get_full_path(db_name)}'
Copy link
Author

Choose a reason for hiding this comment

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

Function global_init refactored with the following changes:

Comment on lines -45 to +42
return HTTPFound(location='/bill/{}'.format(vm.bill_id))
return HTTPFound(location=f'/bill/{vm.bill_id}')
Copy link
Author

Choose a reason for hiding this comment

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

Function details_post refactored with the following changes:

Comment on lines -28 to +29
conn_str = 'sqlite:///' + db_file
print("Connecting to DB at: {}".format(conn_str))
conn_str = f'sqlite:///{db_file}'
print(f"Connecting to DB at: {conn_str}")
Copy link
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:


if not self.user:
self.error = "No user with ID {}.".format(user_id)
self.error = f"No user with ID {user_id}."
Copy link
Author

Choose a reason for hiding this comment

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

Function IndexViewModel.__init__ refactored with the following changes:

return Response(status=404)

return vm.to_dict()
return Response(status=404) if not vm.bill else vm.to_dict()
Copy link
Author

Choose a reason for hiding this comment

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

Function details_get refactored with the following changes:

Comment on lines -45 to +42
return HTTPFound(location='/bill/{}'.format(vm.bill_id))
return HTTPFound(location=f'/bill/{vm.bill_id}')
Copy link
Author

Choose a reason for hiding this comment

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

Function details_post refactored with the following changes:

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