Skip to content

Conversation

@SourceryAI
Copy link

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 master branch, then run:

git fetch https://github.com/sourcery-ai-bot/typeshed master
git merge --ff-only FETCH_HEAD
git reset HEAD^

if not m:
return None
return m.group(1), m.group(2)
return m[1], m[2]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function search_pip_freeze_output refactored with the following changes:

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")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function copy_stubs refactored with the following changes:

sys.exit(f"Error: Cannot parse version number: {version}")
fnam = os.path.join(stub_dir, "METADATA.toml")
version = m.group(0)
version = m[0]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function create_metadata refactored with the following changes:

else:
if entry == "@python2":
continue
elif entry != "@python2":
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function check_stdlib refactored with the following changes:

Comment on lines -73 to +71
else:
if entry in ("@python2", "@tests"):
continue
elif entry not in ("@python2", "@tests"):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function check_stubs refactored with the following changes:

Comment on lines -114 to +116
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)"
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function check_subdirs_discoverable refactored with the following changes:

Comment on lines -152 to +162
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,
)
)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function run_all_tests refactored with the following changes:

Comment on lines -17 to +20
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"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function run_stubtest refactored with the following changes:

with_filenames.extend(unused_files(uu))
for file, uu in with_filenames:
print(file + ":" + uu)
print(f"{file}:{uu}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:

Comment on lines -29 to +43
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")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function unused_files refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant