-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored master 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: master
Are you sure you want to change the base?
Conversation
EMAIL_PROGRAM_FAMILIES = set(( | ||
'Outlook', | ||
'Windows Live Mail', | ||
EMAIL_PROGRAM_FAMILIES = { |
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 69-86
refactored with the following changes:
- Unwrap a constant iterable constructor (
unwrap-iterable-construction
) - Remove duplicate keys when instantiating sets (
remove-duplicate-set-key
)
device = self.is_pc and "PC" or self.device.family | ||
os = ("%s %s" % (self.os.family, self.os.version_string)).strip() | ||
browser = ("%s %s" % (self.browser.family, self.browser.version_string)).strip() | ||
device = "PC" if self.is_pc else self.device.family | ||
os = f"{self.os.family} {self.os.version_string}".strip() | ||
browser = f"{self.browser.family} {self.browser.version_string}".strip() |
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 UserAgent.__str__
refactored with the following changes:
- Replace boolean ternary with inline if expression (
ternary-to-if-expression
) - Replace interpolated string formatting with f-string [×2] (
replace-interpolation-with-fstring
)
if ('Mobile Safari' not in self.ua_string and | ||
self.browser.family != "Firefox Mobile"): | ||
return True | ||
return False | ||
return ( | ||
'Mobile Safari' not in self.ua_string | ||
and self.browser.family != "Firefox Mobile" | ||
) |
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 UserAgent._is_android_tablet
refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else
) - Replace if statement with if expression (
assign-if-exp
) - Simplify boolean if expression (
boolean-if-exp-identity
) - Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
)
if 'Blackberry 95' in self.device.family: # BB Storm devices | ||
return True | ||
if 'Blackberry 95' in self.device.family: # BB Torch devices | ||
return True | ||
return False | ||
return 'Blackberry 95' in self.device.family |
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 UserAgent._is_blackberry_touch_capable_device
refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else
) - Replace if statement with if expression (
assign-if-exp
) - Remove redundant conditional (
remove-redundant-if
) - Simplify boolean if expression (
boolean-if-exp-identity
) - Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
)
This removes the following comments ( why? ):
# BB Storm devices
# BB Torch devices
if self.os.family == 'Firefox OS' and 'Mobile' not in self.browser.family: | ||
return True | ||
return False | ||
return self.os.family == 'Firefox OS' and 'Mobile' not in self.browser.family |
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 UserAgent.is_tablet
refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else
) - Replace if statement with if expression (
assign-if-exp
) - Simplify boolean if expression (
boolean-if-exp-identity
) - Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
)
if 'BlackBerry' in self.os.family and self._is_blackberry_touch_capable_device(): | ||
return True | ||
return False | ||
return bool( | ||
'BlackBerry' in self.os.family | ||
and self._is_blackberry_touch_capable_device() | ||
) |
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 UserAgent.is_touch_capable
refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else
) - Replace if statement with if expression (
assign-if-exp
) - Simplify boolean if expression (
boolean-if-exp-identity
)
self.os.family == 'Windows' and self.os.version_string == 'ME': | ||
self.os.family == 'Windows' and self.os.version_string == 'ME': |
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 UserAgent.is_pc
refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else
) - Replace if statement with if expression (
assign-if-exp
) - Simplify boolean if expression (
boolean-if-exp-identity
) - Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
)
return True if self.device.family == 'Spider' else False | ||
return self.device.family == 'Spider' |
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 UserAgent.is_bot
refactored with the following changes:
- Simplify boolean if expression (
boolean-if-exp-identity
) - Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
)
if self.browser.family in EMAIL_PROGRAM_FAMILIES: | ||
return True | ||
return False | ||
return self.browser.family in EMAIL_PROGRAM_FAMILIES |
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 UserAgent.is_email_client
refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else
) - Replace if statement with if expression (
assign-if-exp
) - Simplify boolean if expression (
boolean-if-exp-identity
) - Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
)
setattr(UserAgentsTest, 'test_' + device, test_wrapper(items)) | ||
setattr(UserAgentsTest, f'test_{device}', test_wrapper(items)) |
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 268-268
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
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:Help us improve this pull request!