Sourcery refactored main branch#7
Conversation
| if before_build is not None: | ||
| if platform_specific: | ||
| monkeypatch.setenv("CIBW_BEFORE_BUILD_" + platform.upper(), before_build) | ||
| monkeypatch.setenv(f"CIBW_BEFORE_BUILD_{platform.upper()}", before_build) |
There was a problem hiding this comment.
Function test_before_build refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| monkeypatch.setenv("CIBW_BUILD_VERBOSITY_" + platform.upper(), str(build_verbosity)) | ||
| monkeypatch.setenv( | ||
| f"CIBW_BUILD_VERBOSITY_{platform.upper()}", | ||
| str(build_verbosity), | ||
| ) | ||
|
|
There was a problem hiding this comment.
Function test_build_verbosity refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| monkeypatch.setenv("CIBW_BEFORE_ALL_" + platform.upper(), before_all) | ||
| monkeypatch.setenv(f"CIBW_BEFORE_ALL_{platform.upper()}", before_all) |
There was a problem hiding this comment.
Function test_before_all refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
74a84a0 to
621ee1d
Compare
| if name == "setup.py": | ||
| if name == "setup.cfg": | ||
| s += "✅" if "python_requires" in contents else "❌" | ||
| elif name == "setup.py": | ||
| if "python_requires" not in contents: | ||
| s += "❌" | ||
| res = parse(contents) | ||
| if res is None: | ||
| s += "⚠️ " | ||
| elif res: | ||
| s += "✅ " + res | ||
| s += f"✅ {res}" | ||
| elif "python_requires" in contents: | ||
| s += "☑️" | ||
|
|
||
| elif name == "setup.cfg": | ||
| s += "✅" if "python_requires" in contents else "❌" |
There was a problem hiding this comment.
Function check_repo refactored with the following changes:
- Simplify conditional into switch-like form (
switch) - Use f-string instead of string concatenation (
use-fstring-for-concatenation)
|
|
||
| urls = [rf["url"] for rf in file_info if file_ident in rf["url"]] | ||
| if urls: | ||
| if urls := [rf["url"] for rf in file_info if file_ident in rf["url"]]: |
There was a problem hiding this comment.
Function CPythonVersions.update_version_macos refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression)
| warnings = detect_warnings(options=options, identifiers=identifiers) | ||
| if warnings: | ||
| if warnings := detect_warnings(options=options, identifiers=identifiers): | ||
| print("\nWarnings:") | ||
| for warning in warnings: | ||
| print(" " + warning) | ||
| print(f" {warning}") |
There was a problem hiding this comment.
Function print_preamble refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression) - Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| msg = f"Invalid archs option {architectures}. " + msg | ||
| msg = f"Invalid archs option {architectures}. {msg}" | ||
| raise ValueError(msg) | ||
|
|
||
| if not architectures: | ||
| msg = "Empty archs option set. " + msg | ||
| msg = f"Empty archs option set. {msg}" |
There was a problem hiding this comment.
Function allowed_architectures_check refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| else: | ||
| output_io = sys.stdout.buffer | ||
|
|
||
| output_io = io.BytesIO() if capture_output else sys.stdout.buffer |
There was a problem hiding this comment.
Function DockerContainer.call refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp) - Replace a[0:x] with a[:x] and a[x:len(a)] with a[x:] (
remove-redundant-slice-index)
| def get_nuget_args(version: str, arch: str, output_directory: Path) -> List[str]: | ||
| platform_suffix = {"32": "x86", "64": "", "ARM64": "arm64"} | ||
| python_name = "python" + platform_suffix[arch] | ||
| python_name = f"python{platform_suffix[arch]}" |
There was a problem hiding this comment.
Function get_nuget_args refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| def _ensure_nuget() -> Path: | ||
| nuget = CIBW_CACHE_PATH / "nuget.exe" | ||
| with FileLock(str(nuget) + ".lock"): | ||
| with FileLock(f'{str(nuget)}.lock'): |
There was a problem hiding this comment.
Function _ensure_nuget refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| installation_path = base_output_dir / (nuget_args[0] + "." + version) / "tools" | ||
| with FileLock(str(base_output_dir) + f"-{version}-{arch}.lock"): | ||
| installation_path = base_output_dir / f'{nuget_args[0]}.{version}' / "tools" | ||
| with FileLock(f"{str(base_output_dir)}-{version}-{arch}.lock"): |
There was a problem hiding this comment.
Function install_cpython refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| assert zip_filename.endswith(extension) | ||
| installation_path = CIBW_CACHE_PATH / zip_filename[: -len(extension)] | ||
| with FileLock(str(installation_path) + ".lock"): | ||
| with FileLock(f'{str(installation_path)}.lock'): |
There was a problem hiding this comment.
Function install_pypy refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
|
|
||
| actual_wheels = utils.cibuildwheel_run(project_dir) | ||
| expected_wheels = [w for w in utils.expected_wheels("spam", "0.1.0")] | ||
| expected_wheels = list(utils.expected_wheels("spam", "0.1.0")) |
There was a problem hiding this comment.
Function test_cpp11 refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension)
|
|
||
| actual_wheels = utils.cibuildwheel_run(project_dir) | ||
| expected_wheels = [w for w in utils.expected_wheels("spam", "0.1.0")] | ||
| expected_wheels = list(utils.expected_wheels("spam", "0.1.0")) |
There was a problem hiding this comment.
Function test_cpp14 refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension)
| return { | ||
| package: version for package, version in re.findall(VERSION_REGEX, constraint_file_text) | ||
| } | ||
| return dict(re.findall(VERSION_REGEX, constraint_file_text)) |
There was a problem hiding this comment.
Function get_versions_from_constraint_file refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension)
| return "11.0" | ||
| else: | ||
| return macosx_deployment_target | ||
| return "11.0" if version_tuple <= (11, 0) else macosx_deployment_target |
There was a problem hiding this comment.
Function _get_arm64_macosx_deployment_target refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| wheels.extend( | ||
| f"{package_name}-{package_version}-{python_abi_tag}-{platform_tag}.whl" | ||
| for platform_tag in platform_tags | ||
| ) |
There was a problem hiding this comment.
Function expected_wheels refactored with the following changes:
- Replace a for append loop with list extend (
for-append-to-extend)
| # check that environment variables can carry binary data, except null characters | ||
| # (https://www.gnu.org/software/libc/manual/html_node/Environment-Variables.html) | ||
| binary_data = bytes(n for n in range(1, 256)) | ||
| binary_data = bytes(range(1, 256)) |
There was a problem hiding this comment.
Function test_binary_output refactored with the following changes:
- Simplify generator expression (
simplify-generator)
| if test_extras is not None: | ||
| if platform_specific: | ||
| monkeypatch.setenv("CIBW_TEST_EXTRAS_" + platform.upper(), test_extras) | ||
| monkeypatch.setenv(f"CIBW_TEST_EXTRAS_{platform.upper()}", test_extras) |
There was a problem hiding this comment.
Function test_test_extras refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| if test_command is not None: | ||
| if platform_specific: | ||
| monkeypatch.setenv("CIBW_TEST_COMMAND_" + platform.upper(), test_command) | ||
| monkeypatch.setenv(f"CIBW_TEST_COMMAND_{platform.upper()}", test_command) |
There was a problem hiding this comment.
Function test_test_command refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| if before_build is not None: | ||
| if platform_specific: | ||
| monkeypatch.setenv("CIBW_BEFORE_BUILD_" + platform.upper(), before_build) | ||
| monkeypatch.setenv(f"CIBW_BEFORE_BUILD_{platform.upper()}", before_build) |
There was a problem hiding this comment.
Function test_before_build refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| monkeypatch.setenv("CIBW_BUILD_VERBOSITY_" + platform.upper(), str(build_verbosity)) | ||
| monkeypatch.setenv( | ||
| f"CIBW_BUILD_VERBOSITY_{platform.upper()}", | ||
| str(build_verbosity), | ||
| ) | ||
|
|
There was a problem hiding this comment.
Function test_build_verbosity refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| monkeypatch.setenv("CIBW_BEFORE_ALL_" + platform.upper(), before_all) | ||
| monkeypatch.setenv(f"CIBW_BEFORE_ALL_{platform.upper()}", before_all) |
There was a problem hiding this comment.
Function test_before_all refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
Sourcery Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 0.22%.
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!