Sourcery Starbot ⭐ refactored tma15/python-tabelog#1
Sourcery Starbot ⭐ refactored tma15/python-tabelog#1SourceryAI wants to merge 1 commit intotma15:masterfrom
Conversation
| return prefecture_map[prefecture] | ||
| except KeyError: | ||
| sys.exit('invalid prefecture name: %s' % prefecture) | ||
| sys.exit(f'invalid prefecture name: {prefecture}') |
There was a problem hiding this comment.
Function convert2prefecture_parameter refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| _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] |
There was a problem hiding this comment.
Function Tabelog.search_restaurant refactored with the following changes:
- Replace interpolated string formatting with f-string [×7] (
replace-interpolation-with-fstring) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
| _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] |
There was a problem hiding this comment.
Function Tabelog.search_review refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
| images = [Image(item) for item in _search_results] | ||
| return images | ||
| return [Image(item) for item in _search_results] |
There was a problem hiding this comment.
Function Tabelog.search_restaurant_image refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| if self._rcd == None: | ||
| if self._rcd is None: |
There was a problem hiding this comment.
Function Restaurant.rcd refactored with the following changes:
- Use x is None rather than x == None (
none-compare)
| if self._category == None: | ||
| if self._category is None: |
There was a problem hiding this comment.
Function Restaurant.category refactored with the following changes:
- Use x is None rather than x == None (
none-compare)
| if self._station == None: | ||
| if self._station is None: |
There was a problem hiding this comment.
Function Restaurant.station refactored with the following changes:
- Use x is None rather than x == None (
none-compare)
| if self._nickname == None: | ||
| if self._nickname is None: |
There was a problem hiding this comment.
Function Review.nickname refactored with the following changes:
- Use x is None rather than x == None (
none-compare)
| if self._visitdate == None: | ||
| if self._visitdate is None: |
There was a problem hiding this comment.
Function Review.visitdate refactored with the following changes:
- Use x is None rather than x == None (
none-compare)
| if self._reviewdate == None: | ||
| if self._reviewdate is None: |
There was a problem hiding this comment.
Function Review.reviewdate refactored with the following changes:
- Use x is None rather than x == None (
none-compare)
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
masterbranch, then run: