Skip to content

Conversation

@SourceryAI
Copy link

Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨

Here's your pull request refactoring your most popular Python repo.

If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch https://github.com/sourcery-ai-bot/python-tabelog master
git merge --ff-only FETCH_HEAD
git reset HEAD^

return prefecture_map[prefecture]
except KeyError:
sys.exit('invalid prefecture name: %s' % prefecture)
sys.exit(f'invalid prefecture name: {prefecture}')
Copy link
Author

Choose a reason for hiding this comment

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

Function convert2prefecture_parameter refactored with the following changes:

Comment on lines -57 to +80
_request_url = 'http://api.tabelog.com/Ver2.1/RestaurantSearch/?Key=%s' % self._access_key
_request_url = f'http://api.tabelog.com/Ver2.1/RestaurantSearch/?Key={self._access_key}'
if latitude:
_request_url = "%sLatitude=%f" % (_request_url, float(latitude))
if longitude:
_request_url = "%sLongitude=%f" % (_request_url, float(longitude))
if datum and latitude and longitude: ### valid if both latitude and longitude are specified
_request_url = "%sDatum=%s" % (self._request_url, str(datum))
_request_url = f"{self._request_url}Datum={str(datum)}"
if search_range:
_request_url = "%sSearchRange=%s" % (_request_url, str(search_range))
_request_url = f"{_request_url}SearchRange={str(search_range)}"
if prefecture:
_request_url = "%s&Prefecture=%s" % (_request_url, str(convert2prefecture_parameter(prefecture)))
_request_url = f"{_request_url}&Prefecture={str(convert2prefecture_parameter(prefecture))}"
if station:
query = [('Station', station)]
_request_url = "%s&%s" % (_request_url, urllib.urlencode(query))
_request_url = f"{_request_url}&{urllib.urlencode(query)}"
if result_set:
_request_url = "%s&ResultSet=%s" % (_request_url, str(result_set))
_request_url = f"{_request_url}&ResultSet={str(result_set)}"
if sort_order:
_request_url = "%s&SortOrder=%s" % (_request_url, str(sort_order))
_request_url = f"{_request_url}&SortOrder={str(sort_order)}"
if page_num:
_request_url = "%s&PageNum=%d" % (_request_url, str(page_num))
if result_datum:
_request_url = "%s&ResultDatum=%d" % (_request_url, str(result_datum))
_search_results = self._extract_items(_request_url)
_restaurants = [Restaurant(item) for item in _search_results]
return _restaurants
return [Restaurant(item) for item in _search_results]
Copy link
Author

Choose a reason for hiding this comment

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

Function Tabelog.search_restaurant refactored with the following changes:

Comment on lines -86 to +89
_request_url = "%s&SortOrder=%s" % (_request_url, sort_order)
_request_url = f"{_request_url}&SortOrder={sort_order}"
if page_num:
_request_url = "%s&PageNum=%d" % (_request_url, int(page_num))
_search_results = self._extract_items(_request_url)
_reviews = [Review(item) for item in _search_results]
return _reviews
return [Review(item) for item in _search_results]
Copy link
Author

Choose a reason for hiding this comment

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

Function Tabelog.search_review refactored with the following changes:

Comment on lines -96 to +94
images = [Image(item) for item in _search_results]
return images
return [Image(item) for item in _search_results]
Copy link
Author

Choose a reason for hiding this comment

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

Function Tabelog.search_restaurant_image refactored with the following changes:

Comment on lines -119 to +116
if self._rcd == None:
if self._rcd is None:
Copy link
Author

Choose a reason for hiding this comment

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

Function Restaurant.rcd refactored with the following changes:

Comment on lines -193 to +190
if self._category == None:
if self._category is None:
Copy link
Author

Choose a reason for hiding this comment

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

Function Restaurant.category refactored with the following changes:

Comment on lines -199 to +196
if self._station == None:
if self._station is None:
Copy link
Author

Choose a reason for hiding this comment

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

Function Restaurant.station refactored with the following changes:

Comment on lines -224 to +221
if self._nickname == None:
if self._nickname is None:
Copy link
Author

Choose a reason for hiding this comment

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

Function Review.nickname refactored with the following changes:

Comment on lines -230 to +227
if self._visitdate == None:
if self._visitdate is None:
Copy link
Author

Choose a reason for hiding this comment

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

Function Review.visitdate refactored with the following changes:

Comment on lines -236 to +233
if self._reviewdate == None:
if self._reviewdate is None:
Copy link
Author

Choose a reason for hiding this comment

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

Function Review.reviewdate 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