Sourcery Starbot ⭐ refactored agusdmb/typeshed#1
Sourcery Starbot ⭐ refactored agusdmb/typeshed#1SourceryAI wants to merge 1 commit intoagusdmb:masterfrom
Conversation
| if not m: | ||
| return None | ||
| return m.group(1), m.group(2) | ||
| return m[1], m[2] |
There was a problem hiding this comment.
Function search_pip_freeze_output refactored with the following changes:
- Replace m.group(x) with m[x] for re.Match objects (
use-getitem-for-re-match-groups)
| shutil.copytree(src_dir, os.path.join(stub_dir, package)) | ||
| else: | ||
| src_file = os.path.join("out", package + ".pyi") | ||
| src_file = os.path.join("out", f"{package}.pyi") |
There was a problem hiding this comment.
Function copy_stubs refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| sys.exit(f"Error: Cannot parse version number: {version}") | ||
| fnam = os.path.join(stub_dir, "METADATA.toml") | ||
| version = m.group(0) | ||
| version = m[0] |
There was a problem hiding this comment.
Function create_metadata refactored with the following changes:
- Replace m.group(x) with m[x] for re.Match objects (
use-getitem-for-re-match-groups)
| else: | ||
| if entry == "@python2": | ||
| continue | ||
| elif entry != "@python2": |
There was a problem hiding this comment.
Function check_stdlib refactored with the following changes:
- Merge else clause's nested if statement into elif (
merge-else-if-into-elif) - Lift code into else after jump in control flow (
reintroduce-else) - Remove redundant continue statement (
remove-redundant-continue)
| else: | ||
| if entry in ("@python2", "@tests"): | ||
| continue | ||
| elif entry not in ("@python2", "@tests"): |
There was a problem hiding this comment.
Function check_stubs refactored with the following changes:
- Merge else clause's nested if statement into elif (
merge-else-if-into-elif) - Lift code into else after jump in control flow (
reintroduce-else) - Remove redundant continue statement (
remove-redundant-continue)
| raise SystemExit("Cannot find typeshed subdir at {} (specify parent dir via --typeshed-location)".format(p)) | ||
| raise SystemExit( | ||
| f"Cannot find typeshed subdir at {p} (specify parent dir via --typeshed-location)" | ||
| ) |
There was a problem hiding this comment.
Function check_subdirs_discoverable refactored with the following changes:
- Replace call to format with f-string. (
use-fstring-for-formatting)
| run_pytype(filename=f, python_version=python_version, typeshed_location=typeshed_location) if not dry_run else None | ||
| None | ||
| if dry_run | ||
| else run_pytype( | ||
| filename=f, | ||
| python_version=python_version, | ||
| typeshed_location=typeshed_location, | ||
| ) | ||
| ) | ||
|
|
There was a problem hiding this comment.
Function run_all_tests refactored with the following changes:
- Swap if/else branches of if expression to remove negation (
swap-if-expression) - Replace call to format with f-string. (
use-fstring-for-formatting)
| version_allowlist = "py{}{}.txt".format(sys.version_info.major, sys.version_info.minor) | ||
| platform_allowlist = "{}.txt".format(sys.platform) | ||
| combined_allowlist = "{}-py{}{}.txt".format(sys.platform, sys.version_info.major, sys.version_info.minor) | ||
| version_allowlist = f"py{sys.version_info.major}{sys.version_info.minor}.txt" | ||
| platform_allowlist = f"{sys.platform}.txt" | ||
| combined_allowlist = f"{sys.platform}-py{sys.version_info.major}{sys.version_info.minor}.txt" | ||
|
|
There was a problem hiding this comment.
Function run_stubtest refactored with the following changes:
- Replace call to format with f-string. (
use-fstring-for-formatting)
| with_filenames.extend(unused_files(uu)) | ||
| for file, uu in with_filenames: | ||
| print(file + ":" + uu) | ||
| print(f"{file}:{uu}") |
There was a problem hiding this comment.
Function main refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| version = "py{}{}".format(sys.version_info[0], sys.version_info[1]) | ||
| files = ["py3_common.txt", version + ".txt", sys.platform + ".txt", sys.platform + "-" + version + ".txt"] | ||
| version = f"py{sys.version_info[0]}{sys.version_info[1]}" | ||
| files = [ | ||
| "py3_common.txt", | ||
| f"{version}.txt", | ||
| f"{sys.platform}.txt", | ||
| f"{sys.platform}-{version}.txt", | ||
| ] | ||
|
|
||
| found = [] | ||
| for file in files: | ||
| path = _ALLOWLIST_PATH / file | ||
| if find_unused_in_file(unused, path): | ||
| found.append((path.as_posix(), unused)) | ||
| if not found: | ||
| raise ValueError("unused item {} not found in any allowlist file".format(unused)) | ||
| raise ValueError(f"unused item {unused} not found in any allowlist file") |
There was a problem hiding this comment.
Function unused_files refactored with the following changes:
- Replace call to format with f-string. (
use-fstring-for-formatting) - Use f-string instead of string concatenation (
use-fstring-for-concatenation)
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
masterbranch, then run: