Skip to content

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Jun 13, 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 -131 to +142
if extraRE[0] == '(':
extraRE = r'(?P<extra>%s)' % extraRE
else:
extraRE = r"(?P<extra>%s)" % extraRE
extraRE = r'(?P<extra>%s)' % extraRE
if extraSep:
extraRE = extraSep + extraRE
else:
extraRE = "(?P<extra>)"

protoRE = "(%s)" % "|".join(PROTOCOLS.keys())
route = (r"/(?P<resource>%s)%s/(?P<protocol>%s)/?(?P<session_id>[0-9a-zA-Z]*?)/?((?P<protocol_init>\d*?)|(?P<xhr_path>\w*?))/?(?P<jsonp_index>\d*?)" % (resource, extraRE, protoRE), cls)
return route
return (
r"/(?P<resource>%s)%s/(?P<protocol>%s)/?(?P<session_id>[0-9a-zA-Z]*?)/?((?P<protocol_init>\d*?)|(?P<xhr_path>\w*?))/?(?P<jsonp_index>\d*?)"
% (resource, extraRE, protoRE),
cls,
)
Copy link
Author

Choose a reason for hiding this comment

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

Function SocketIOHandler.routes refactored with the following changes:

  • Hoist repeated code outside conditional statement
  • Inline variable that is only used once

Comment on lines -211 to +216
return filter(lambda t: (t[0] == '*' or t[0].lower() == host.lower()) and (t[1] == '*' or t[1] == int(port)), origins)
return filter(
lambda t: ((t[0] == '*' or t[0].lower() == host.lower()))
and t[1] in ['*', int(port)],
origins,
)

Copy link
Author

Choose a reason for hiding this comment

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

Function SocketIOProtocol.verify_origin refactored with the following changes:

  • Replace multiple comparisons of same variable with in operator

Comment on lines -221 to +226
if self.asynchronous:
out_fh = self.output_handle
else:
out_fh = self

out_fh = self.output_handle if self.asynchronous else self
Copy link
Author

Choose a reason for hiding this comment

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

Function SocketIOProtocol.send refactored with the following changes:

  • Replace if statement with if expression

"""Write method which all protocols must define to
indicate how to push to their wire"""
self.warning("[socketio protocol] Default call to _write. NOOP. [%s]" % message)
pass
Copy link
Author

Choose a reason for hiding this comment

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

Function SocketIOProtocol._write refactored with the following changes:

  • Remove redundant pass statement

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.

2 participants