-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored main branch #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| print ("Quoted %s at (bid:%s, ask:%s, price:%s)" % (stock, bid_price, ask_price, price)) | ||
| print(f"Quoted {stock} at (bid:{bid_price}, ask:{ask_price}, price:{price})") | ||
|
|
||
| print ("Ratio %s" % getRatio(prices['ABC'], prices['DEF'])) | ||
| print(f"Ratio {getRatio(prices['ABC'], prices['DEF'])}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 62-64 refactored with the following changes:
- Replace interpolated string formatting with f-string [×2] (
replace-interpolation-with-fstring)
| REALTIME = True | ||
| SIM_LENGTH = timedelta(days = 365 * 5) | ||
| MARKET_OPEN = datetime.today().replace(hour = 0, minute = 30, second = 0) | ||
| MARKET_OPEN = datetime.now().replace(hour = 0, minute = 30, second = 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 46-46 refactored with the following changes:
- Replace datetime.datetime.today() with datetime.datetime.now() (
use-datetime-now-not-today)
| order, size, _ = buy[0] | ||
| new_book = clear_order(order, size, sell) | ||
| if new_book: | ||
| if new_book := clear_order(order, size, sell): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function clear_book refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression)
| if hasattr(handler, "__route__"): | ||
| if None != re.search(handler.__route__, req_handler.path): | ||
| req_handler.send_response(200) | ||
| req_handler.send_header('Content-Type', 'application/json') | ||
| req_handler.send_header('Access-Control-Allow-Origin', '*') | ||
| req_handler.end_headers() | ||
| params = read_params(req_handler.path) | ||
| data = json.dumps(handler(routes, params)) + '\n' | ||
| req_handler.wfile.write(bytes(data, encoding = 'utf-8')) | ||
| return | ||
| if ( | ||
| hasattr(handler, "__route__") | ||
| and re.search(handler.__route__, req_handler.path) != None | ||
| ): | ||
| req_handler.send_response(200) | ||
| req_handler.send_header('Content-Type', 'application/json') | ||
| req_handler.send_header('Access-Control-Allow-Origin', '*') | ||
| req_handler.end_headers() | ||
| params = read_params(req_handler.path) | ||
| data = json.dumps(handler(routes, params)) + '\n' | ||
| req_handler.wfile.write(bytes(data, encoding = 'utf-8')) | ||
| return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function get refactored with the following changes:
- Merge nested if conditions (
merge-nested-ifs) - Ensure constant in comparison is on the right (
flip-comparison)
| self._book_1 = dict() | ||
| self._book_2 = dict() | ||
| self._book_1 = {} | ||
| self._book_2 = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function App.__init__ refactored with the following changes:
- Replace dict() with {} [×2] (
dict-literal)
| REALTIME = True | ||
| SIM_LENGTH = timedelta(days = 365 * 5) | ||
| MARKET_OPEN = datetime.today().replace(hour = 0, minute = 30, second = 0) | ||
| MARKET_OPEN = datetime.now().replace(hour = 0, minute = 30, second = 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 46-46 refactored with the following changes:
- Replace datetime.datetime.today() with datetime.datetime.now() (
use-datetime-now-not-today)
| order, size, _ = buy[0] | ||
| new_book = clear_order(order, size, sell) | ||
| if new_book: | ||
| if new_book := clear_order(order, size, sell): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function clear_book refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression)
| if hasattr(handler, "__route__"): | ||
| if None != re.search(handler.__route__, req_handler.path): | ||
| req_handler.send_response(200) | ||
| req_handler.send_header('Content-Type', 'application/json') | ||
| req_handler.send_header('Access-Control-Allow-Origin', '*') | ||
| req_handler.end_headers() | ||
| params = read_params(req_handler.path) | ||
| data = json.dumps(handler(routes, params)) + '\n' | ||
| req_handler.wfile.write(bytes(data, encoding = 'utf-8')) | ||
| return | ||
| if ( | ||
| hasattr(handler, "__route__") | ||
| and re.search(handler.__route__, req_handler.path) != None | ||
| ): | ||
| req_handler.send_response(200) | ||
| req_handler.send_header('Content-Type', 'application/json') | ||
| req_handler.send_header('Access-Control-Allow-Origin', '*') | ||
| req_handler.end_headers() | ||
| params = read_params(req_handler.path) | ||
| data = json.dumps(handler(routes, params)) + '\n' | ||
| req_handler.wfile.write(bytes(data, encoding = 'utf-8')) | ||
| return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function get refactored with the following changes:
- Merge nested if conditions (
merge-nested-ifs) - Ensure constant in comparison is on the right (
flip-comparison)
| self._book_1 = dict() | ||
| self._book_2 = dict() | ||
| self._book_1 = {} | ||
| self._book_2 = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function App.__init__ refactored with the following changes:
- Replace dict() with {} [×2] (
dict-literal)
| print ('Query received @ t%s' % t) | ||
| print(f'Query received @ t{t}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function App.handle_query refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.08%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
Branch
mainrefactored 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
mainbranch, then run:Help us improve this pull request!