Skip to content

Bump protobuf to 4.21.*; delete google/__init__.pyi #8360

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

Merged
merged 6 commits into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stubs/protobuf/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = "3.20.*"
version = "4.21.*"
Copy link
Contributor

Choose a reason for hiding this comment

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

This appears to have created a 4.21.0.0 for whatever reason. It's not strictly problematic, but it's a bit weird to have

https://pypi.org/project/types-protobuf/4.21.0.0/
and
https://pypi.org/project/protobuf/4.21.9/

Copy link
Contributor

Choose a reason for hiding this comment

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

just a bit awkward to have a 4 section version for the types and a 3 section version for the regular one.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I made this change to stub_uploader a month or two ago. The reason is to more clearly distinguish type versions from upstream versions and to demonstrate the intended version compatibility range of 4.21.*.
E.g., if we bumped the third number you may naively think that types-protobuf 4.21.1 or 4.21.2 corresponded to those versions of protobuf.

Copy link
Collaborator

@hauntsaninja hauntsaninja Nov 26, 2022

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

ah intentional. Cool. Didn't realize. Thanks for the explanation

extra_description = "Generated with aid from mypy-protobuf v3.4.0"
Empty file removed stubs/protobuf/google/__init__.pyi
Empty file.
38 changes: 24 additions & 14 deletions tests/mypy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
strip_comments,
)

try:
from mypy.api import run as mypy_run
except ImportError:
print_error("Cannot import mypy. Did you install it?")
sys.exit(1)

SUPPORTED_VERSIONS = ["3.11", "3.10", "3.9", "3.8", "3.7"]
SUPPORTED_PLATFORMS = ("linux", "win32", "darwin")
DIRECTORIES_TO_TEST = [Path("stdlib"), Path("stubs")]
Expand Down Expand Up @@ -198,13 +204,7 @@ def add_configuration(configurations: list[MypyDistConf], distribution: str) ->
configurations.append(MypyDistConf(module_name, values.copy()))


def run_mypy(args: TestConfig, configurations: list[MypyDistConf], files: list[Path]) -> ReturnCode:
try:
from mypy.api import run as mypy_run
except ImportError:
print_error("Cannot import mypy. Did you install it?")
sys.exit(1)

def run_mypy(args: TestConfig, configurations: list[MypyDistConf], files: list[Path], *, testing_stdlib: bool) -> ReturnCode:
with tempfile.NamedTemporaryFile("w+") as temp:
temp.write("[mypy]\n")
for dist_conf in configurations:
Expand All @@ -213,7 +213,7 @@ def run_mypy(args: TestConfig, configurations: list[MypyDistConf], files: list[P
temp.write(f"{k} = {v}\n")
temp.flush()

flags = get_mypy_flags(args, temp.name)
flags = get_mypy_flags(args, temp.name, testing_stdlib=testing_stdlib)
mypy_args = [*flags, *map(str, files)]
if args.verbose:
print("running mypy", " ".join(mypy_args))
Expand All @@ -238,8 +238,8 @@ def run_mypy(args: TestConfig, configurations: list[MypyDistConf], files: list[P
return exit_code


def get_mypy_flags(args: TestConfig, temp_name: str) -> list[str]:
return [
def get_mypy_flags(args: TestConfig, temp_name: str, *, testing_stdlib: bool) -> list[str]:
flags = [
"--python-version",
args.version,
"--show-traceback",
Expand All @@ -260,6 +260,9 @@ def get_mypy_flags(args: TestConfig, temp_name: str) -> list[str]:
"--config-file",
temp_name,
]
if not testing_stdlib:
flags.append("--explicit-package-bases")
return flags


def add_third_party_files(
Expand Down Expand Up @@ -315,7 +318,14 @@ def test_third_party_distribution(distribution: str, args: TestConfig) -> TestRe
print_error("no files found")
sys.exit(1)

code = run_mypy(args, configurations, files)
prev_mypypath = os.getenv("MYPYPATH")
os.environ["MYPYPATH"] = os.pathsep.join(str(Path("stubs", dist)) for dist in seen_dists)
code = run_mypy(args, configurations, files, testing_stdlib=False)
if prev_mypypath is None:
del os.environ["MYPYPATH"]
else:
os.environ["MYPYPATH"] = prev_mypypath

return TestResults(code, len(files))


Expand All @@ -333,16 +343,16 @@ def test_stdlib(code: int, args: TestConfig) -> TestResults:

if files:
print(f"Testing stdlib ({len(files)} files)...")
print("Running mypy " + " ".join(get_mypy_flags(args, "/tmp/...")))
this_code = run_mypy(args, [], files)
print("Running mypy " + " ".join(get_mypy_flags(args, "/tmp/...", testing_stdlib=True)))
this_code = run_mypy(args, [], files, testing_stdlib=True)
code = max(code, this_code)

return TestResults(code, len(files))


def test_third_party_stubs(code: int, args: TestConfig) -> TestResults:
print("Testing third-party packages...")
print("Running mypy " + " ".join(get_mypy_flags(args, "/tmp/...")))
print("Running mypy " + " ".join(get_mypy_flags(args, "/tmp/...", testing_stdlib=False)))
files_checked = 0
gitignore_spec = get_gitignore_spec()

Expand Down