-
Notifications
You must be signed in to change notification settings - Fork 0
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
Sourcery refactored master branch #1
base: master
Are you sure you want to change the base?
Conversation
copyright = str(datetime.date.today().year) + ', SuHun Han (ssut)' | ||
copyright = f'{str(datetime.date.today().year)}, SuHun Han (ssut)' |
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 59-59
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
for t in enumerate(service_urls): | ||
for _ in enumerate(service_urls): |
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 Translator.__init__
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
extra = {} | ||
|
||
for index, category in response_parts_name_mapping.items(): | ||
extra[category] = data[index] if ( | ||
index < len(data) and data[index]) else None | ||
|
||
return extra | ||
return { | ||
category: data[index] if (index < len(data) and data[index]) else None | ||
for index, category in response_parts_name_mapping.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.
Function Translator._parse_extra_data
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
) - Convert for loop into dictionary comprehension (
dict-comprehension
)
translated = ''.join([d[0] if d[0] else '' for d in data[0]]) | ||
translated = ''.join([d[0] or '' for d in data[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.
Function Translator.translate
refactored with the following changes:
- Simplify if expression by using or (
or-if-exp-identity
)
self.host = host if 'http' in host else 'https://' + host | ||
self.host = host if 'http' in host else f'https://{host}' |
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 TokenAcquirer.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
raw_tkk = self.RE_TKK.search(r.text) | ||
if raw_tkk: | ||
if raw_tkk := self.RE_TKK.search(r.text): |
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 TokenAcquirer._update
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
) - Replace call to format with f-string. (
use-fstring-for-formatting
)
d = rshift(a, d) if '+' == b[c + 1] else a << d | ||
a = a + d & 4294967295 if '+' == b[c] else a ^ d | ||
d = rshift(a, d) if b[c + 1] == '+' else a << d | ||
a = a + d & 4294967295 if b[c] == '+' else a ^ d |
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 TokenAcquirer._xr
refactored with the following changes:
- Ensure constant in comparison is on the right (
flip-comparison
)
@@ -166,7 +165,6 @@ def acquire(self, text): | |||
# just append if l is less than 128(ascii: DEL) | |||
if l < 128: | |||
e.append(l) | |||
# append calculated value if l is less than 2048 |
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 TokenAcquirer.acquire
refactored with the following changes:
- Merge consecutive list appends into a single extend (
merge-list-appends-into-extend
) - Remove unnecessary calls to
enumerate
when the index is not used (remove-unused-enumerate
) - Replace call to format with f-string. (
use-fstring-for-formatting
)
This removes the following comments ( why? ):
# append calculated value if l is less than 2048
tk = self.acquire(text) | ||
return tk | ||
return self.acquire(text) |
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 TokenAcquirer.do
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
converted = json.loads(text) | ||
return converted | ||
return json.loads(text) |
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 legacy_format_json
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
Sourcery Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 0.09%.
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
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!