-
Notifications
You must be signed in to change notification settings - Fork 3
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 develop branch #3
base: develop
Are you sure you want to change the base?
Conversation
nonCommand = getattr(namespace, "non_command", None) | ||
if nonCommand: | ||
if nonCommand := getattr(namespace, "non_command", None): |
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 main.RemainderSetAction.__call__
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
if baseDir: | ||
baseDir = os.path.normcase(baseDir) | ||
if baseDir.endswith(os.path.sep): | ||
baseDir = baseDir[0:-1] | ||
return baseDir | ||
else: | ||
if not baseDir: | ||
# Converts empty string to None | ||
return None | ||
baseDir = os.path.normcase(baseDir) | ||
if baseDir.endswith(os.path.sep): | ||
baseDir = baseDir[:-1] | ||
return baseDir |
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 normalizeBaseDir
refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches
) - Remove unnecessary else after guard condition (
remove-unnecessary-else
) - Replace a[0:x] with a[:x] and a[x:len(a)] with a[x:] (
remove-redundant-slice-index
)
return os.path.join(self.manifestSectionDir, manifestHash + ".json") | ||
return os.path.join(self.manifestSectionDir, f'{manifestHash}.json') |
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 ManifestSection.manifestPath
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
["/" + k + collapseBasedirInCmdPath(arg) for arg in arguments[k]] | ||
[ | ||
f'/{k}{collapseBasedirInCmdPath(arg)}' | ||
for arg in arguments[k] | ||
] | ||
) | ||
|
||
else: | ||
commandLine.extend(["/" + k + arg for arg in arguments[k]]) | ||
commandLine.extend([f'/{k}{arg}' for arg in arguments[k]]) |
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 ManifestRepository.getManifestHash
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self._mutexName = "Local\\" + mutexName | ||
self._mutexName = f'Local\\{mutexName}' |
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 CacheLock.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
setOfSources = set(sourceFile for sourceFile, _ in sourceFiles) | ||
setOfSources = {sourceFile for sourceFile, _ in sourceFiles} |
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 filterSourceFiles
refactored with the following changes:
- Replace list(), dict() or set() with comprehension (
collection-builtin-to-comprehension
)
key_prefix=(getStringHash(self.fileStrategy.dir) + "_").encode("UTF-8"), | ||
key_prefix=f'{getStringHash(self.fileStrategy.dir)}_'.encode("UTF-8"), |
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 CacheMemcacheStrategy.connect
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
remote = self.remoteCache.getEntry(key) | ||
if remote: | ||
if remote := self.remoteCache.getEntry(key): |
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 CacheFileWithMemcacheFallbackStrategy.getEntry
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
local = self.localCache.getManifest(manifestHash) | ||
if local: | ||
if local := self.localCache.getManifest(manifestHash): | ||
printTraceStatement( | ||
"{} local manifest hit for {}".format(self, manifestHash) | ||
) | ||
return local | ||
remote = self.remoteCache.getManifest(manifestHash) | ||
if remote: | ||
if remote := self.remoteCache.getManifest(manifestHash): |
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 CacheFileWithMemcacheFallbackStrategy.getManifest
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
out = [] | ||
lines = text.splitlines(True) | ||
for line in lines: | ||
out.append(line.replace("\r", "<CR>").replace("\n", "<LN>")) | ||
out = [line.replace("\r", "<CR>").replace("\n", "<LN>") for line in lines] |
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 TestCompileRuns.testPipedOutput.debugLinebreaks
refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block
) - Convert for loop into list comprehension (
list-comprehension
)
mpFlag = "/MP" + str(len(sources)) | ||
mpFlag = f'/MP{len(sources)}' |
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 RunParallelBase.testOutput
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Remove unnecessary calls to
str()
from formatted values in f-strings (remove-str-from-fstring
)
cls.sources = [] | ||
for i in range(1, TestConcurrency.NUM_SOURCE_FILES+1): | ||
cls.sources.append(os.path.join(ASSETS_DIR, 'concurrency', 'file{:02d}.cpp'.format(i))) | ||
cls.sources = [ | ||
os.path.join(ASSETS_DIR, 'concurrency', 'file{:02d}.cpp'.format(i)) | ||
for i in range(1, TestConcurrency.NUM_SOURCE_FILES + 1) | ||
] |
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 TestConcurrency.setUpClass
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
)
else: | ||
# We just want to know if we got a proper source file. | ||
# Other AnalysisErrors are ignored. | ||
pass |
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 TestAnalyzeCommandLine._testSourceFilesOk
refactored with the following changes:
- Remove redundant pass statement (
remove-redundant-pass
)
This removes the following comments ( why? ):
# Other AnalysisErrors are ignored.
# We just want to know if we got a proper source file.
for i in range(0, 999): | ||
for i in range(999): |
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 TestCompression.assertEntrySizeIsCorrect
refactored with the following changes:
- Replace range(0, x) with range(x) (
remove-zero-from-range
)
Sourcery Code Quality Report✅ Merging this PR will increase 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
develop
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
develop
branch, then run:Help us improve this pull request!