From 1f898d0737de0c8d36ca7b9fd17364b11edb2f46 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 28 Feb 2024 23:20:38 -0500 Subject: [PATCH 01/21] Configuration updates --- .flake8 | 53 ++++++++++-------------------------- .pre-commit-config.yaml | 1 - CONTRIBUTING.md | 1 - pyproject.toml | 51 ++++++++++++++++++++++++++-------- pyrightconfig.testcases.json | 2 +- requirements-tests.txt | 1 - 6 files changed, 55 insertions(+), 54 deletions(-) diff --git a/.flake8 b/.flake8 index e07faf68fdc2..5c527abb5f08 100644 --- a/.flake8 +++ b/.flake8 @@ -1,44 +1,19 @@ -# The following rules come from plugins that are not used by typeshed. -# Since typeshed stubs them, they can still be expected to be found in a -# developer's venv for intellisense and reference reasons -# A flake8-builtins -# D flake8-docstrings -# N8 pep8-naming -# SIM flake8-simplify -# RST flake8-rst-docstrings -# TYP flake8-typing-imports - -# The following rules are incompatible with or enforced by Black: -# E203 whitespace before ':' -- scripts only -# E301 expected 1 blank line -# E302 expected 2 blank lines -# E305 expected 2 blank lines -# E501 line too long -# E701 Multiple statements on one line (colon) -- disallows "..." on the same line - -# Some rules are considered irrelevant to stub files: -# B All flake8-bugbear rules are .py-specific -# F401 imported but unused -- does not recognize re-exports -# https://github.com/PyCQA/pyflakes/issues/474 - -# Rules that are out of the control of stub authors: -# E741 ambiguous variable name -# F403 import *' used; unable to detect undefined names -# F405 defined from star imports - [flake8] -extend-ignore = A, D, N8, SIM, RST, TYP, E301, E302, E305, E501, E701 +# NQA: Ruff won't warn about redundant `# noqa: Y` +# Y: Flake8 is only used to run flake8-pyi, everything else is in Ruff +# F821: Until https://github.com/astral-sh/ruff/issues/3011 is fixed, we need flake8-pyi's monkeypatching +select = NQA, Y, F821 +# Ignore rules normally excluded by default +extend-ignore = Y090 per-file-ignores = - *.py: E203 - *.pyi: B, E741, F401, F403, F405 - # Since typing.pyi defines "overload" this is not recognized by Flake8 as typing.overload. - # Unfortunately, Flake8 does not allow to "noqa" just a specific error inside the file itself. - # https://github.com/PyCQA/flake8/issues/1079 - # F811 redefinition of unused '...' - stdlib/typing.pyi: B, E741, F401, F403, F405, F811 - # Generated protobuf files include docstrings, - # and import some things from typing_extensions that could be imported from typing - *_pb2.pyi: B, E741, F401, F403, F405, Y021, Y023, Y026, Y053, Y054 + # We should only need to noqa Y and F821 codes in .pyi files + *.py: NQA + # Generated protobuf files: + # Y021: Include docstrings + # Y023: Alias typing as typing_extensions + # Y026: Have implicit type aliases + # Y053: have literals >50 characters long + *_pb2.pyi: Y021, Y023, Y026, Y053 exclude = .venv*,.git noqa_require_code = true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f8d2cee56233..9bf998ec4bdd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,6 @@ repos: hooks: - id: flake8 additional_dependencies: - - "flake8-bugbear==24.1.17" # must match requirements-tests.txt - "flake8-noqa==1.4.0" # must match requirements-tests.txt - "flake8-pyi==24.1.0" # must match requirements-tests.txt types: [file] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bc3aeefb8d5a..1dd7fd6fdb84 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -108,7 +108,6 @@ you're free to do so. Either run the following manually... Our code is also linted using [`Flake8`](https://github.com/pycqa/flake8), with plugins [`flake8-pyi`](https://github.com/pycqa/flake8-pyi), -[`flake8-bugbear`](https://github.com/PyCQA/flake8-bugbear), and [`flake8-noqa`](https://github.com/plinss/flake8-noqa). As with our other checks, running Flake8 before filing a PR is not required. However, if you wish to run Flake8 diff --git a/pyproject.toml b/pyproject.toml index c3e1cdd1c112..e9973d2067d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,11 +24,16 @@ exclude = [ ] [tool.ruff.lint] -select = [ +# We still use flake8-pyi and flake8-noqa to check these (see .flake8 config file) +external = ["F821", "NQA", "Y"] +extend-select = [ + "B", # flake8-bugbear "FA", # flake8-future-annotations "I", # isort - # Only enable rules that have safe autofixes: - "F401", # Remove unused imports + "RUF", # Ruff-specific and unused-noqa + "UP", # pyupgrade + # PYI: only enable rules that always autofix, avoids duplicate # noqa with flake8-pyi + # See https://github.com/plinss/flake8-noqa/issues/22 "PYI009", # use `...`, not `pass`, in empty class bodies "PYI010", # function bodies must be empty "PYI012", # class bodies must not contain `pass` @@ -39,14 +44,38 @@ select = [ "PYI032", # use `object`, not `Any`, as the second parameter to `__eq__` "PYI055", # multiple `type[T]` usages in a union "PYI058", # use `Iterator` as the return type for `__iter__` methods - "UP004", # Remove explicit `object` inheritance - "UP006", # PEP-585 autofixes - "UP007", # PEP-604 autofixes - "UP013", # Class-based syntax for TypedDicts - "UP014", # Class-based syntax for NamedTuples - "UP019", # Use str over typing.Text - "UP035", # import from typing, not typing_extensions, wherever possible - "UP039", # don't use parens after a class definition with no bases +] +ignore = [ + ### + # Rules we don't want or don't agree with + ### + # We like explicit open modes + "UP015", # redundant-open-modes + # Used for direct, non-sublcass type comparison, for example: `type(val) is str` + # see https://github.com/astral-sh/ruff/issues/6465 + "E721", # Do not compare types, use `isinstance()` + ### + # False-positives, but already checked by type-checkers + ### + # Ruff doesn't support multi-file analysis yet: https://github.com/astral-sh/ruff/issues/5295 + "RUF013", # PEP 484 prohibits implicit `Optional` +] + +[tool.ruff.lint.extend-per-file-ignores] +# Generated protobuf files: +"*_pb2.pyi" = [ + "UP036", # outdated-version-block +] +"*.pyi" = [ + # Rules that are out of the control of stub authors: + "B006", # Do not use mutable data structures for argument defaults + "E501", # Line too long + "E741", # ambiguous variable name + "F403", # `from . import *` used; unable to detect undefined names + # False positives in stubs + "F821", # Undefined name: https://github.com/astral-sh/ruff/issues/3011 + # FIXME: Fix these in stubs, then remove these entries + "F405", # may be undefined, or defined from star imports ] [tool.ruff.lint.isort] diff --git a/pyrightconfig.testcases.json b/pyrightconfig.testcases.json index 059df46cc608..e2898dd56268 100644 --- a/pyrightconfig.testcases.json +++ b/pyrightconfig.testcases.json @@ -15,7 +15,7 @@ // See https://github.com/python/typeshed/pull/8083 "enableTypeIgnoreComments": true, // If a test case uses this anti-pattern, there's likely a reason and annoying to `type: ignore`. - // Let flake8-bugbear flag it (B006) + // Let Ruff flag it (B006) "reportCallInDefaultInitializer": "none", // Too strict and not needed for type testing "reportMissingSuperCall": "none", diff --git a/requirements-tests.txt b/requirements-tests.txt index ab7cc475ff0b..b20110d2c17e 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -3,7 +3,6 @@ # "tool.typeshed" section in pyproject.toml for additional type checkers. black==24.1.1 # must match .pre-commit-config.yaml flake8==7.0.0 # must match .pre-commit-config.yaml -flake8-bugbear==24.1.17 # must match .pre-commit-config.yaml flake8-noqa==1.4.0 # must match .pre-commit-config.yaml flake8-pyi==24.1.0 # must match .pre-commit-config.yaml mypy==1.8.0 From 6046354e3be2a751af805d1500434f9a930bc26b Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 28 Feb 2024 23:22:47 -0500 Subject: [PATCH 02/21] noqa comments fixes --- stubs/WebOb/webob/exc.pyi | 2 +- stubs/fanstatic/fanstatic/registry.pyi | 2 +- stubs/olefile/olefile/olefile.pyi | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stubs/WebOb/webob/exc.pyi b/stubs/WebOb/webob/exc.pyi index 4856ca590740..35874c96df76 100644 --- a/stubs/WebOb/webob/exc.pyi +++ b/stubs/WebOb/webob/exc.pyi @@ -41,7 +41,7 @@ class WSGIHTTPException(Response, HTTPException): def generate_response(self, environ: WSGIEnvironment, start_response: StartResponse) -> Iterable[bytes]: ... @property def wsgi_response(self) -> Self: ... # type:ignore[override] - def __str__(self) -> str: ... # type:ignore[override] # noqaY029 + def __str__(self) -> str: ... # type:ignore[override] # noqa: Y029 class HTTPError(WSGIHTTPException): ... class HTTPRedirection(WSGIHTTPException): ... diff --git a/stubs/fanstatic/fanstatic/registry.pyi b/stubs/fanstatic/fanstatic/registry.pyi index 9612bb5f37f2..aa32a8f58d3b 100644 --- a/stubs/fanstatic/fanstatic/registry.pyi +++ b/stubs/fanstatic/fanstatic/registry.pyi @@ -21,7 +21,7 @@ class Registry(dict[str, _NamedT]): @property @abstractmethod def ENTRY_POINT(self) -> str: ... - def __init__(self, items: Iterable[_NamedT] = ()) -> None: ... # noqaY011 + def __init__(self, items: Iterable[_NamedT] = ()) -> None: ... def add(self, item: _NamedT) -> None: ... def load_items_from_entry_points(self) -> None: ... def make_item_from_entry_point(self, entry_point: EntryPoint) -> Any: ... diff --git a/stubs/olefile/olefile/olefile.pyi b/stubs/olefile/olefile/olefile.pyi index 642abc9fe49b..b1df2da29a2b 100644 --- a/stubs/olefile/olefile/olefile.pyi +++ b/stubs/olefile/olefile/olefile.pyi @@ -179,13 +179,13 @@ class OleFileIO: raise_defects: int = 40, write_mode: bool = False, debug: bool = False, - path_encoding: str | None = DEFAULT_PATH_ENCODING, # noqaY011 + path_encoding: str | None = DEFAULT_PATH_ENCODING, # noqa: Y011 ) -> None: ... def __del__(self) -> None: ... def __enter__(self) -> Self: ... def __exit__(self, *args: object) -> None: ... def _raise_defect( - self, defect_level: int, message: str, exception_type: type[Exception] = OleFileError # noqaY011 + self, defect_level: int, message: str, exception_type: type[Exception] = OleFileError # noqa: Y011 ) -> None: ... def _decode_utf16_str(self, utf16_str: bytes, errors: str = "replace") -> bytes: ... def open(self, filename: IO[bytes] | bytes | str, write_mode: bool = False) -> None: ... From ec9bfbd951bae4321bd33b435109894cd500cb7e Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 28 Feb 2024 23:24:31 -0500 Subject: [PATCH 03/21] Code improvements from new Ruff checks --- scripts/runtests.py | 2 +- scripts/stubsabot.py | 4 ++-- test_cases/stdlib/typing/check_all.py | 4 +--- tests/mypy_test.py | 2 +- tests/pytype_test.py | 2 +- tests/regr_test.py | 2 +- tests/stubtest_third_party.py | 6 +++--- tests/typecheck_typeshed.py | 2 +- tests/utils.py | 2 +- 9 files changed, 12 insertions(+), 14 deletions(-) diff --git a/scripts/runtests.py b/scripts/runtests.py index bec0e47ccaa0..c373ba903ada 100755 --- a/scripts/runtests.py +++ b/scripts/runtests.py @@ -101,7 +101,7 @@ def main() -> None: strict_params = _get_strict_params(path) print(f"\nRunning Pyright ({'stricter' if strict_params else 'base' } configs) for Python {python_version}...") pyright_result = subprocess.run( - [sys.executable, "tests/pyright_test.py", path, "--pythonversion", python_version] + strict_params, + [sys.executable, "tests/pyright_test.py", path, "--pythonversion", python_version, *strict_params], stderr=subprocess.PIPE, text=True, ) diff --git a/scripts/stubsabot.py b/scripts/stubsabot.py index b2a86e31d0f6..64c6c475c38c 100644 --- a/scripts/stubsabot.py +++ b/scripts/stubsabot.py @@ -48,7 +48,7 @@ def from_cmd_arg(cls, cmd_arg: str) -> ActionLevel: try: return cls[cmd_arg] except KeyError: - raise argparse.ArgumentTypeError(f'Argument must be one of "{list(cls.__members__)}"') + raise argparse.ArgumentTypeError(f'Argument must be one of "{list(cls.__members__)}"') from None nothing = 0, "make no changes" local = 1, "make changes that affect local repo" @@ -516,7 +516,7 @@ async def determine_action(stub_path: Path, session: aiohttp.ClientSession) -> U ) -@functools.lru_cache() +@functools.lru_cache def get_origin_owner() -> str: output = subprocess.check_output(["git", "remote", "get-url", "origin"], text=True).strip() match = re.match(r"(git@github.com:|https://github.com/)(?P[^/]+)/(?P[^/\s]+)", output) diff --git a/test_cases/stdlib/typing/check_all.py b/test_cases/stdlib/typing/check_all.py index b75e8a8d02a6..3c3f56813c69 100644 --- a/test_cases/stdlib/typing/check_all.py +++ b/test_cases/stdlib/typing/check_all.py @@ -1,10 +1,8 @@ -from __future__ import annotations - # pyright: reportWildcardImportFromLibrary=false - """ This tests that star imports work when using "all += " syntax. """ +from __future__ import annotations import sys from typing import * # noqa: F403 diff --git a/tests/mypy_test.py b/tests/mypy_test.py index 552dbd15cc77..f9d0ea3cc839 100755 --- a/tests/mypy_test.py +++ b/tests/mypy_test.py @@ -279,7 +279,7 @@ def run_mypy( flags.append("--no-site-packages") mypy_args = [*flags, *map(str, files)] - mypy_command = [venv_info.python_exe, "-m", "mypy"] + mypy_args + mypy_command = [venv_info.python_exe, "-m", "mypy", *mypy_args] if args.verbose: print(colored(f"running {' '.join(mypy_command)}", "blue")) result = subprocess.run(mypy_command, capture_output=True, text=True, env=env_vars) diff --git a/tests/pytype_test.py b/tests/pytype_test.py index 43c8fca03d82..ee314f3f0b28 100755 --- a/tests/pytype_test.py +++ b/tests/pytype_test.py @@ -210,7 +210,7 @@ def run_all_tests(*, files_to_test: Sequence[str], print_stderr: bool, dry_run: missing_modules = get_missing_modules(files_to_test) print("Testing files with pytype...") for i, f in enumerate(files_to_test): - python_version = "{0.major}.{0.minor}".format(sys.version_info) + python_version = f"{sys.version_info.major}.{sys.version_info.minor}" if dry_run: stderr = None else: diff --git a/tests/regr_test.py b/tests/regr_test.py index efa46e2b8a93..b0f689d95b95 100755 --- a/tests/regr_test.py +++ b/tests/regr_test.py @@ -211,7 +211,7 @@ def run_testcases( continue flags.append(str(path)) - mypy_command = [python_exe, "-m", "mypy"] + flags + mypy_command = [python_exe, "-m", "mypy", *flags] if verbosity is Verbosity.VERBOSE: description = f"{package.name}/{version}/{platform}" msg = f"{description}: {mypy_command=}\n" diff --git a/tests/stubtest_third_party.py b/tests/stubtest_third_party.py index 9b4e301d049e..be17ec616364 100755 --- a/tests/stubtest_third_party.py +++ b/tests/stubtest_third_party.py @@ -53,7 +53,7 @@ def run_stubtest( # If tool.stubtest.stubtest_requirements exists, run "pip install" on it. if stubtest_settings.stubtest_requirements: - pip_cmd = [pip_exe, "install"] + stubtest_settings.stubtest_requirements + pip_cmd = [pip_exe, "install", *stubtest_settings.stubtest_requirements] try: subprocess.run(pip_cmd, check=True, capture_output=True) except subprocess.CalledProcessError as e: @@ -67,7 +67,7 @@ def run_stubtest( # TODO: Maybe find a way to cache these in CI dists_to_install = [dist_req, get_mypy_req()] dists_to_install.extend(requirements.external_pkgs) # Internal requirements are added to MYPYPATH - pip_cmd = [pip_exe, "install"] + dists_to_install + pip_cmd = [pip_exe, "install", *dists_to_install] try: subprocess.run(pip_cmd, check=True, capture_output=True) except subprocess.CalledProcessError as e: @@ -134,7 +134,7 @@ def run_stubtest( print(file=sys.stderr) else: print(f"Re-running stubtest with --generate-allowlist.\nAdd the following to {allowlist_path}:", file=sys.stderr) - ret = subprocess.run(stubtest_cmd + ["--generate-allowlist"], env=stubtest_env, capture_output=True) + ret = subprocess.run([*stubtest_cmd, "--generate-allowlist"], env=stubtest_env, capture_output=True) print_command_output(ret) return False diff --git a/tests/typecheck_typeshed.py b/tests/typecheck_typeshed.py index 4094399f06df..32f30fd73d89 100755 --- a/tests/typecheck_typeshed.py +++ b/tests/typecheck_typeshed.py @@ -21,7 +21,7 @@ parser = argparse.ArgumentParser(description="Run mypy on typeshed's own code in the `scripts` and `tests` directories.") parser.add_argument( "dir", - choices=DIRECTORIES_TO_TEST + (EMPTY,), + choices=(*DIRECTORIES_TO_TEST, EMPTY), nargs="*", action="extend", help=f"Test only these top-level typeshed directories (defaults to {DIRECTORIES_TO_TEST!r})", diff --git a/tests/utils.py b/tests/utils.py index 2fd376314057..c1b24256f753 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -119,7 +119,7 @@ def get_all_testcase_directories() -> list[PackageInfo]: potential_testcase_dir = testcase_dir_from_package_name(package_name) if potential_testcase_dir.is_dir(): testcase_directories.append(PackageInfo(package_name, potential_testcase_dir)) - return [PackageInfo("stdlib", Path("test_cases"))] + sorted(testcase_directories) + return [PackageInfo("stdlib", Path("test_cases")), *sorted(testcase_directories)] # ==================================================================== From c459fa5adc6a4fd1b6dc67348beb933448ebeed4 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 28 Feb 2024 23:24:48 -0500 Subject: [PATCH 04/21] noqa comments updates --- stdlib/builtins.pyi | 2 +- stdlib/typing.pyi | 2 ++ stubs/six/six/moves/builtins.pyi | 5 ++++- test_cases/stdlib/builtins/check_list.py | 3 ++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 73e75dc34e6e..f154d4d72377 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -100,7 +100,7 @@ class object: def __class__(self) -> type[Self]: ... # Ignore errors about type mismatch between property getter and setter @__class__.setter - def __class__(self, __type: type[object]) -> None: ... # noqa: F811 + def __class__(self, __type: type[object]) -> None: ... def __init__(self) -> None: ... def __new__(cls) -> Self: ... # N.B. `object.__setattr__` and `object.__delattr__` are heavily special-cased by type checkers. diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index 5d01be539016..068bc4e44c91 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -1,3 +1,5 @@ +# Since this module defines "overload" it is not recognized by Ruff as typing.overload +# ruff: noqa: F811 # TODO: The collections import is required, otherwise mypy crashes. # https://github.com/python/mypy/issues/16744 import collections # noqa: F401 # pyright: ignore diff --git a/stubs/six/six/moves/builtins.pyi b/stubs/six/six/moves/builtins.pyi index 9596ba032aa0..b497e50424ad 100644 --- a/stubs/six/six/moves/builtins.pyi +++ b/stubs/six/six/moves/builtins.pyi @@ -1 +1,4 @@ -from builtins import * +# flake8: noqa: NQA102 # https://github.com/plinss/flake8-noqa/issues/22 +# six explicitely re-exports builtins. Normally this is something we'd want to avoid. +# But this is specifically a compatibility package. +from builtins import * # noqa: UP029 diff --git a/test_cases/stdlib/builtins/check_list.py b/test_cases/stdlib/builtins/check_list.py index 4113f5c66182..40c460727bed 100644 --- a/test_cases/stdlib/builtins/check_list.py +++ b/test_cases/stdlib/builtins/check_list.py @@ -15,7 +15,8 @@ def asd(self) -> int: return 2 -combined = [Foo()] + [Bar()] +# Testing for concatenation +combined = [Foo()] + [Bar()] # noqa: RUF005 assert_type(combined, List[Union[Foo, Bar]]) for item in combined: assert_type(item.asd(), int) From ff0f3af62237e1e3b74e856bbc8671488340dc79 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 29 Feb 2024 04:31:01 +0000 Subject: [PATCH 05/21] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/socket.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/socket.pyi b/stdlib/socket.pyi index ce5e35228fe4..375000fd395d 100644 --- a/stdlib/socket.pyi +++ b/stdlib/socket.pyi @@ -803,7 +803,7 @@ def getfqdn(name: str = "") -> str: ... if sys.version_info >= (3, 11): def create_connection( address: tuple[str | None, int], - timeout: float | None = ..., # noqa: F811 + timeout: float | None = ..., source_address: _Address | None = None, *, all_errors: bool = False, @@ -811,7 +811,7 @@ if sys.version_info >= (3, 11): else: def create_connection( - address: tuple[str | None, int], timeout: float | None = ..., source_address: _Address | None = None # noqa: F811 + address: tuple[str | None, int], timeout: float | None = ..., source_address: _Address | None = None ) -> socket: ... def has_dualstack_ipv6() -> bool: ... From f03df93fafb5b6d309059d521459bcf93806c0cc Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 28 Feb 2024 23:42:16 -0500 Subject: [PATCH 06/21] Missed an instance of flake8-bugbear --- tests/check_consistent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/check_consistent.py b/tests/check_consistent.py index 1fc40db576c9..1abb4d635148 100755 --- a/tests/check_consistent.py +++ b/tests/check_consistent.py @@ -23,7 +23,7 @@ # These type checkers and linters must have exact versions in the requirements file to ensure # consistent CI runs. -linters = {"black", "flake8", "flake8-bugbear", "flake8-noqa", "flake8-pyi", "ruff", "mypy", "pytype"} +linters = {"black", "flake8", "flake8-noqa", "flake8-pyi", "ruff", "mypy", "pytype"} def assert_consistent_filetypes( From 51d8dd051ab4b4b2e1b3e504179b3abf28b51cb0 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 28 Feb 2024 23:58:54 -0500 Subject: [PATCH 07/21] typo --- stubs/six/six/moves/builtins.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/six/six/moves/builtins.pyi b/stubs/six/six/moves/builtins.pyi index b497e50424ad..1f3812602c5e 100644 --- a/stubs/six/six/moves/builtins.pyi +++ b/stubs/six/six/moves/builtins.pyi @@ -1,4 +1,4 @@ # flake8: noqa: NQA102 # https://github.com/plinss/flake8-noqa/issues/22 -# six explicitely re-exports builtins. Normally this is something we'd want to avoid. +# six explicitly re-exports builtins. Normally this is something we'd want to avoid. # But this is specifically a compatibility package. from builtins import * # noqa: UP029 From 85075f1cfe29e1b43f141bc91b6754870f53f042 Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 29 Feb 2024 12:15:52 -0500 Subject: [PATCH 08/21] Add pyupgrade check outdated-version-block (UP036) --- pyproject.toml | 1 + scripts/sync_tensorflow_protobuf_stubs.sh | 3 ++- .../compiler/xla/autotune_results_pb2.pyi | 7 +------ .../example_parser_configuration_pb2.pyi | 7 +------ .../tensorflow/core/example/example_pb2.pyi | 7 +------ .../tensorflow/core/example/feature_pb2.pyi | 7 +------ .../framework/allocation_description_pb2.pyi | 7 +------ .../core/framework/attr_value_pb2.pyi | 7 +------ .../core/framework/cost_graph_pb2.pyi | 7 +------ .../core/framework/dataset_metadata_pb2.pyi | 7 +------ .../tensorflow/core/framework/dataset_pb2.pyi | 7 +------ .../core/framework/device_attributes_pb2.pyi | 7 +------ .../tensorflow/core/framework/function_pb2.pyi | 7 +------ .../tensorflow/core/framework/graph_pb2.pyi | 17 ++++++----------- .../core/framework/kernel_def_pb2.pyi | 7 +------ .../core/framework/log_memory_pb2.pyi | 7 +------ .../tensorflow/core/framework/node_def_pb2.pyi | 7 +------ .../tensorflow/core/framework/op_def_pb2.pyi | 7 +------ .../framework/optimized_function_graph_pb2.pyi | 7 +------ .../core/framework/reader_base_pb2.pyi | 7 +------ .../core/framework/resource_handle_pb2.pyi | 7 +------ .../core/framework/step_stats_pb2.pyi | 7 +------ .../core/framework/tensor_description_pb2.pyi | 7 +------ .../tensorflow/core/framework/tensor_pb2.pyi | 7 +------ .../core/framework/tensor_shape_pb2.pyi | 7 +------ .../core/framework/tensor_slice_pb2.pyi | 9 ++------- .../tensorflow/core/framework/versions_pb2.pyi | 7 +------ .../tensorflow/core/protobuf/cluster_pb2.pyi | 7 +------ .../protobuf/composite_tensor_variant_pb2.pyi | 7 +------ .../core/protobuf/control_flow_pb2.pyi | 7 +------ .../core/protobuf/coordination_config_pb2.pyi | 7 +------ .../tensorflow/core/protobuf/debug_pb2.pyi | 13 ++++--------- .../core/protobuf/device_filters_pb2.pyi | 7 +------ .../core/protobuf/device_properties_pb2.pyi | 7 +------ .../distributed_runtime_payloads_pb2.pyi | 7 +------ .../core/protobuf/fingerprint_pb2.pyi | 7 +------ .../core/protobuf/graph_debug_info_pb2.pyi | 7 +------ .../tensorflow/core/protobuf/meta_graph_pb2.pyi | 7 +------ .../core/protobuf/named_tensor_pb2.pyi | 9 ++------- .../core/protobuf/queue_runner_pb2.pyi | 7 +------ .../core/protobuf/remote_tensor_handle_pb2.pyi | 7 +------ .../core/protobuf/rewriter_config_pb2.pyi | 4 ++-- .../core/protobuf/saved_model_pb2.pyi | 7 +------ .../core/protobuf/service_config_pb2.pyi | 7 +------ .../tensorflow/core/protobuf/snapshot_pb2.pyi | 7 +------ .../core/protobuf/tensorflow_server_pb2.pyi | 7 +------ .../core/protobuf/tpu/dynamic_padding_pb2.pyi | 7 +------ .../protobuf/trackable_object_graph_pb2.pyi | 7 +------ .../core/protobuf/transport_options_pb2.pyi | 7 +------ .../core/util/memmapped_file_system_pb2.pyi | 7 +------ .../core/util/saved_tensor_slice_pb2.pyi | 7 +------ .../keras/protobuf/projector_config_pb2.pyi | 7 +------ .../keras/protobuf/saved_metadata_pb2.pyi | 7 +------ .../python/keras/protobuf/versions_pb2.pyi | 7 +------ .../tsl/protobuf/bfc_memory_map_pb2.pyi | 7 +------ .../tsl/protobuf/coordination_config_pb2.pyi | 7 +------ .../distributed_runtime_payloads_pb2.pyi | 7 +------ .../tensorflow/tsl/protobuf/histogram_pb2.pyi | 7 +------ .../tensorflow/tsl/protobuf/rpc_options_pb2.pyi | 7 +------ 59 files changed, 71 insertions(+), 349 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c3e1cdd1c112..12e84c88ba87 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,6 +46,7 @@ select = [ "UP014", # Class-based syntax for NamedTuples "UP019", # Use str over typing.Text "UP035", # import from typing, not typing_extensions, wherever possible + "UP036", # Version block is outdated for minimum Python version "UP039", # don't use parens after a class definition with no bases ] diff --git a/scripts/sync_tensorflow_protobuf_stubs.sh b/scripts/sync_tensorflow_protobuf_stubs.sh index 11471a86c2aa..943e56920999 100755 --- a/scripts/sync_tensorflow_protobuf_stubs.sh +++ b/scripts/sync_tensorflow_protobuf_stubs.sh @@ -61,7 +61,8 @@ rm tensorflow/compiler/xla/service/hlo_execution_profile_data_pb2.pyi \ tensorflow/core/protobuf/worker_service_pb2.pyi \ tensorflow/core/util/example_proto_fast_parsing_test_pb2.pyi -ruff check "$REPO_ROOT/stubs/tensorflow/tensorflow" --fix-only +# --unsafe-fixes to apply outdated-version-block (UP036) +ruff check "$REPO_ROOT/stubs/tensorflow/tensorflow" --fix-only --unsafe-fixes black "$REPO_ROOT/stubs/tensorflow/tensorflow" sed --in-place="" \ diff --git a/stubs/tensorflow/tensorflow/compiler/xla/autotune_results_pb2.pyi b/stubs/tensorflow/tensorflow/compiler/xla/autotune_results_pb2.pyi index 1f107829d73a..beee5221bfa6 100644 --- a/stubs/tensorflow/tensorflow/compiler/xla/autotune_results_pb2.pyi +++ b/stubs/tensorflow/tensorflow/compiler/xla/autotune_results_pb2.pyi @@ -18,18 +18,13 @@ limitations under the License. """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message import tensorflow.tsl.protobuf.autotuning_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/example/example_parser_configuration_pb2.pyi b/stubs/tensorflow/tensorflow/core/example/example_parser_configuration_pb2.pyi index 7b24d84e01e1..9a0ec205c04c 100644 --- a/stubs/tensorflow/tensorflow/core/example/example_parser_configuration_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/example/example_parser_configuration_pb2.pyi @@ -4,7 +4,7 @@ isort:skip_file Protocol messages for describing the configuration of the ExampleParserOp.""" import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -13,11 +13,6 @@ import tensorflow.core.framework.tensor_pb2 import tensorflow.core.framework.tensor_shape_pb2 import tensorflow.core.framework.types_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/example/example_pb2.pyi b/stubs/tensorflow/tensorflow/core/example/example_pb2.pyi index cd4bcd511a7e..c123b10085e7 100644 --- a/stubs/tensorflow/tensorflow/core/example/example_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/example/example_pb2.pyi @@ -5,17 +5,12 @@ Protocol messages for describing input data Examples for machine learning model training or inference. """ import builtins -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.message import tensorflow.core.example.feature_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/example/feature_pb2.pyi b/stubs/tensorflow/tensorflow/core/example/feature_pb2.pyi index 42bfb4d4f9f0..9f087bfbc559 100644 --- a/stubs/tensorflow/tensorflow/core/example/feature_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/example/feature_pb2.pyi @@ -57,17 +57,12 @@ Example Features for a movie recommendation application: """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/framework/allocation_description_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/allocation_description_pb2.pyi index e1d5638202f1..72810915bb86 100644 --- a/stubs/tensorflow/tensorflow/core/framework/allocation_description_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/allocation_description_pb2.pyi @@ -3,16 +3,11 @@ isort:skip_file """ import builtins -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/framework/attr_value_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/attr_value_pb2.pyi index 11566fd7fb19..3e42d11f5fe2 100644 --- a/stubs/tensorflow/tensorflow/core/framework/attr_value_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/attr_value_pb2.pyi @@ -4,7 +4,7 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -13,11 +13,6 @@ import tensorflow.core.framework.tensor_pb2 import tensorflow.core.framework.tensor_shape_pb2 import tensorflow.core.framework.types_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/framework/cost_graph_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/cost_graph_pb2.pyi index 1aa0b7a153a3..92cab2446fc2 100644 --- a/stubs/tensorflow/tensorflow/core/framework/cost_graph_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/cost_graph_pb2.pyi @@ -4,7 +4,7 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -12,11 +12,6 @@ import google.protobuf.message import tensorflow.core.framework.tensor_shape_pb2 import tensorflow.core.framework.types_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/framework/dataset_metadata_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/dataset_metadata_pb2.pyi index ff792ea47c46..be0a6828bf1a 100644 --- a/stubs/tensorflow/tensorflow/core/framework/dataset_metadata_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/dataset_metadata_pb2.pyi @@ -3,16 +3,11 @@ isort:skip_file """ import builtins -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/framework/dataset_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/dataset_pb2.pyi index b2e987481ccf..993b0a25c984 100644 --- a/stubs/tensorflow/tensorflow/core/framework/dataset_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/dataset_pb2.pyi @@ -4,7 +4,7 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -13,11 +13,6 @@ import tensorflow.core.framework.tensor_pb2 import tensorflow.core.framework.tensor_shape_pb2 import tensorflow.core.framework.types_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/framework/device_attributes_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/device_attributes_pb2.pyi index 4b1dbd3d3ffa..0c9279720f8c 100644 --- a/stubs/tensorflow/tensorflow/core/framework/device_attributes_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/device_attributes_pb2.pyi @@ -4,17 +4,12 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/framework/function_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/function_pb2.pyi index 4f920a308aa4..a4f7ee17cc4c 100644 --- a/stubs/tensorflow/tensorflow/core/framework/function_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/function_pb2.pyi @@ -4,7 +4,7 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -13,11 +13,6 @@ import tensorflow.core.framework.attr_value_pb2 import tensorflow.core.framework.node_def_pb2 import tensorflow.core.framework.op_def_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/framework/graph_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/graph_pb2.pyi index 9ff82c9d8cff..0ca220f9fa1d 100644 --- a/stubs/tensorflow/tensorflow/core/framework/graph_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/graph_pb2.pyi @@ -4,7 +4,7 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -13,11 +13,6 @@ import tensorflow.core.framework.function_pb2 import tensorflow.core.framework.node_def_pb2 import tensorflow.core.framework.versions_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final @@ -46,7 +41,7 @@ class GraphDef(google.protobuf.message.Message): @property def library(self) -> tensorflow.core.framework.function_pb2.FunctionDefLibrary: """"library" provides user-defined functions. - + Naming: * library.function.name are in a flat namespace. NOTE: We may need to change it to be hierarchical to support @@ -58,14 +53,14 @@ class GraphDef(google.protobuf.message.Message): * If node[i].op is the name of one function in "library", node[i] is deemed as a function call. Otherwise, node[i].op must be a primitive operation supported by the runtime. - - + + Function call semantics: - + * The callee may start execution as soon as some of its inputs are ready. The caller may want to use Tuple() mechanism to ensure all inputs are ready in the same time. - + * The consumer of return values may start executing as soon as the return values the consumer depends on are ready. The consumer may want to use Tuple() mechanism to ensure the diff --git a/stubs/tensorflow/tensorflow/core/framework/kernel_def_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/kernel_def_pb2.pyi index 53c54aab27da..3e3e93d8be80 100644 --- a/stubs/tensorflow/tensorflow/core/framework/kernel_def_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/kernel_def_pb2.pyi @@ -4,18 +4,13 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message import tensorflow.core.framework.attr_value_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/framework/log_memory_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/log_memory_pb2.pyi index d3c6f0dd8261..8ed5e51e41d6 100644 --- a/stubs/tensorflow/tensorflow/core/framework/log_memory_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/log_memory_pb2.pyi @@ -3,17 +3,12 @@ isort:skip_file """ import builtins -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.message import tensorflow.core.framework.tensor_description_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/framework/node_def_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/node_def_pb2.pyi index 8e8b352b7837..70fd99f66056 100644 --- a/stubs/tensorflow/tensorflow/core/framework/node_def_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/node_def_pb2.pyi @@ -4,7 +4,7 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -12,11 +12,6 @@ import google.protobuf.message import tensorflow.core.framework.attr_value_pb2 import tensorflow.core.framework.full_type_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/framework/op_def_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/op_def_pb2.pyi index 0e384331dd90..37ff910d3f27 100644 --- a/stubs/tensorflow/tensorflow/core/framework/op_def_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/op_def_pb2.pyi @@ -4,7 +4,7 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -14,11 +14,6 @@ import tensorflow.core.framework.full_type_pb2 import tensorflow.core.framework.resource_handle_pb2 import tensorflow.core.framework.types_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/framework/optimized_function_graph_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/optimized_function_graph_pb2.pyi index 8709c3987750..967a5a1de385 100644 --- a/stubs/tensorflow/tensorflow/core/framework/optimized_function_graph_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/optimized_function_graph_pb2.pyi @@ -4,7 +4,7 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -12,11 +12,6 @@ import google.protobuf.message import tensorflow.core.framework.graph_pb2 import tensorflow.core.framework.types_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/framework/reader_base_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/reader_base_pb2.pyi index 3f395b4570c0..2bc0aafe35a9 100644 --- a/stubs/tensorflow/tensorflow/core/framework/reader_base_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/reader_base_pb2.pyi @@ -3,16 +3,11 @@ isort:skip_file """ import builtins -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/framework/resource_handle_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/resource_handle_pb2.pyi index d92b2f765265..c2f282c80d62 100644 --- a/stubs/tensorflow/tensorflow/core/framework/resource_handle_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/resource_handle_pb2.pyi @@ -4,7 +4,7 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -12,11 +12,6 @@ import google.protobuf.message import tensorflow.core.framework.tensor_shape_pb2 import tensorflow.core.framework.types_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/framework/step_stats_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/step_stats_pb2.pyi index 8261e5730ea2..85375199ae39 100644 --- a/stubs/tensorflow/tensorflow/core/framework/step_stats_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/step_stats_pb2.pyi @@ -4,7 +4,7 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -12,11 +12,6 @@ import google.protobuf.message import tensorflow.core.framework.allocation_description_pb2 import tensorflow.core.framework.tensor_description_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/framework/tensor_description_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/tensor_description_pb2.pyi index f6c348b8a14b..3fb9b3ea3737 100644 --- a/stubs/tensorflow/tensorflow/core/framework/tensor_description_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/tensor_description_pb2.pyi @@ -3,7 +3,7 @@ isort:skip_file """ import builtins -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.message @@ -11,11 +11,6 @@ import tensorflow.core.framework.allocation_description_pb2 import tensorflow.core.framework.tensor_shape_pb2 import tensorflow.core.framework.types_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/framework/tensor_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/tensor_pb2.pyi index 393b94d909f6..db6b81b6ae3b 100644 --- a/stubs/tensorflow/tensorflow/core/framework/tensor_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/tensor_pb2.pyi @@ -4,7 +4,7 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -13,11 +13,6 @@ import tensorflow.core.framework.resource_handle_pb2 import tensorflow.core.framework.tensor_shape_pb2 import tensorflow.core.framework.types_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/framework/tensor_shape_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/tensor_shape_pb2.pyi index 37a6a5279201..04c31cdeeffe 100644 --- a/stubs/tensorflow/tensorflow/core/framework/tensor_shape_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/tensor_shape_pb2.pyi @@ -4,17 +4,12 @@ isort:skip_file Protocol buffer representing the shape of tensors.""" import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/framework/tensor_slice_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/tensor_slice_pb2.pyi index cfc3e361d699..d938d4101f8a 100644 --- a/stubs/tensorflow/tensorflow/core/framework/tensor_slice_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/tensor_slice_pb2.pyi @@ -4,17 +4,12 @@ isort:skip_file Protocol buffer representing slices of a tensor""" import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final @@ -51,7 +46,7 @@ class TensorSliceProto(google.protobuf.message.Message): @property def extent(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___TensorSliceProto.Extent]: """Extent of the slice in all tensor dimensions. - + Must have one entry for each of the dimension of the tensor that this slice belongs to. The order of sizes is the same as the order of dimensions in the TensorShape. diff --git a/stubs/tensorflow/tensorflow/core/framework/versions_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/versions_pb2.pyi index 4df61f398301..ec22a6f1d778 100644 --- a/stubs/tensorflow/tensorflow/core/framework/versions_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/versions_pb2.pyi @@ -4,17 +4,12 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/cluster_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/cluster_pb2.pyi index e9f986e3a24e..8fb3dd48bde8 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/cluster_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/cluster_pb2.pyi @@ -18,17 +18,12 @@ limitations under the License. """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/composite_tensor_variant_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/composite_tensor_variant_pb2.pyi index eb143db57da9..3fe68dfe4262 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/composite_tensor_variant_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/composite_tensor_variant_pb2.pyi @@ -3,17 +3,12 @@ isort:skip_file """ import builtins -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.message import tensorflow.core.protobuf.struct_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/control_flow_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/control_flow_pb2.pyi index cb0fd3576554..dd8044f8add8 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/control_flow_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/control_flow_pb2.pyi @@ -4,17 +4,12 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/coordination_config_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/coordination_config_pb2.pyi index fcd757622079..c4855fe17c53 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/coordination_config_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/coordination_config_pb2.pyi @@ -4,17 +4,12 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/debug_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/debug_pb2.pyi index 106a26b01072..d5b0b7164ea6 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/debug_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/debug_pb2.pyi @@ -4,17 +4,12 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final @@ -49,7 +44,7 @@ class DebugTensorWatch(google.protobuf.message.Message): @property def debug_urls(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: """URL(s) for debug targets(s). - + Supported URL formats are: - file:///foo/tfdbg_dump: Writes out Event content to file /foo/tfdbg_dump. Assumes all directories can be created if they don't @@ -58,10 +53,10 @@ class DebugTensorWatch(google.protobuf.message.Message): service running at localhost:11011 with the event. - memcbk:///event_key: Routes tensors to clients using the callback registered with the DebugCallbackRegistry for event_key. - + Each debug op listed in debug_ops will publish its output tensor (debug signal) to all URLs in debug_urls. - + N.B. Session::Run() supports concurrent invocations of the same inputs (feed keys), outputs and target nodes. If such concurrent invocations are to be debugged, the callers of Session::Run() must use distinct diff --git a/stubs/tensorflow/tensorflow/core/protobuf/device_filters_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/device_filters_pb2.pyi index e26f3a083842..5d480d0fb6e0 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/device_filters_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/device_filters_pb2.pyi @@ -18,17 +18,12 @@ limitations under the License. """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/device_properties_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/device_properties_pb2.pyi index b3ec2632a7a8..c2b892f12a64 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/device_properties_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/device_properties_pb2.pyi @@ -18,17 +18,12 @@ limitations under the License. """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/distributed_runtime_payloads_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/distributed_runtime_payloads_pb2.pyi index ed8dd9ae681e..b27a37c32cc3 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/distributed_runtime_payloads_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/distributed_runtime_payloads_pb2.pyi @@ -4,17 +4,12 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/fingerprint_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/fingerprint_pb2.pyi index be397855b80c..fc486666a960 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/fingerprint_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/fingerprint_pb2.pyi @@ -3,17 +3,12 @@ isort:skip_file """ import builtins -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.message import tensorflow.core.framework.versions_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/graph_debug_info_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/graph_debug_info_pb2.pyi index ae0527450348..182aa9a42819 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/graph_debug_info_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/graph_debug_info_pb2.pyi @@ -4,17 +4,12 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/meta_graph_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/meta_graph_pb2.pyi index 0506fc7a8b1a..cb5eee1183af 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/meta_graph_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/meta_graph_pb2.pyi @@ -4,7 +4,7 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.any_pb2 import google.protobuf.descriptor @@ -18,11 +18,6 @@ import tensorflow.core.protobuf.saved_object_graph_pb2 import tensorflow.core.protobuf.saver_pb2 import tensorflow.core.protobuf.struct_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/named_tensor_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/named_tensor_pb2.pyi index b45f134db7f6..d649783ff22d 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/named_tensor_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/named_tensor_pb2.pyi @@ -3,17 +3,12 @@ isort:skip_file """ import builtins -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.message import tensorflow.core.framework.tensor_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final @@ -30,7 +25,7 @@ class NamedTensorProto(google.protobuf.message.Message): def tensor(self) -> tensorflow.core.framework.tensor_pb2.TensorProto: """The client can populate a TensorProto using a tensorflow::Tensor`, or directly using the protobuf field accessors. - + The client specifies whether the returned tensor values should be filled tensor fields (float_val, int_val, etc.) or encoded in a compact form in tensor.tensor_content. diff --git a/stubs/tensorflow/tensorflow/core/protobuf/queue_runner_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/queue_runner_pb2.pyi index 59d932074fc1..f362ad0d0ca8 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/queue_runner_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/queue_runner_pb2.pyi @@ -4,18 +4,13 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message import tensorflow.tsl.protobuf.error_codes_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/remote_tensor_handle_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/remote_tensor_handle_pb2.pyi index 55607e50b4a8..a394c73a80b7 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/remote_tensor_handle_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/remote_tensor_handle_pb2.pyi @@ -4,7 +4,7 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -12,11 +12,6 @@ import google.protobuf.message import tensorflow.core.framework.tensor_shape_pb2 import tensorflow.core.framework.types_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/rewriter_config_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/rewriter_config_pb2.pyi index 9bf638aa42bd..883a7d707ea5 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/rewriter_config_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/rewriter_config_pb2.pyi @@ -420,13 +420,13 @@ class RewriterConfig(google.protobuf.message.Message): """If non-empty, will use this as an alternative way to specify a list of optimizations to turn on and the order of the optimizations (replacing the meta-optimizer). - + Of the RewriterConfig options, only the AutoParallel configuration options (the auto_parallel field) apply to manually requested optimization passes ("autoparallel"). Memory optimization passes ("memory") invoked here are not configurable (in contrast to memory optimization passes through the meta-optimizer) and act only on manual op annotations. - + Custom optimizers (see custom_optimizers) that are not part of this schedule will be run after - in the order that they were specified. """ diff --git a/stubs/tensorflow/tensorflow/core/protobuf/saved_model_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/saved_model_pb2.pyi index 7c32f95070fd..da656e1b0886 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/saved_model_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/saved_model_pb2.pyi @@ -4,18 +4,13 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message import tensorflow.core.protobuf.meta_graph_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/service_config_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/service_config_pb2.pyi index 99465a6b94ef..96ae66ee2f29 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/service_config_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/service_config_pb2.pyi @@ -4,18 +4,13 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message import tensorflow.core.protobuf.data_service_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/snapshot_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/snapshot_pb2.pyi index 7db51bb8518b..78ec3103f6d0 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/snapshot_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/snapshot_pb2.pyi @@ -4,7 +4,7 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -13,11 +13,6 @@ import tensorflow.core.framework.tensor_pb2 import tensorflow.core.framework.tensor_shape_pb2 import tensorflow.core.framework.types_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/tensorflow_server_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/tensorflow_server_pb2.pyi index 781baf8375ad..4b1516ef16b0 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/tensorflow_server_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/tensorflow_server_pb2.pyi @@ -17,7 +17,7 @@ limitations under the License. ============================================================================== """ import builtins -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.message @@ -25,11 +25,6 @@ import tensorflow.core.protobuf.cluster_pb2 import tensorflow.core.protobuf.config_pb2 import tensorflow.core.protobuf.device_filters_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/tpu/dynamic_padding_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/tpu/dynamic_padding_pb2.pyi index b296008931f0..081d859f7553 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/tpu/dynamic_padding_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/tpu/dynamic_padding_pb2.pyi @@ -3,16 +3,11 @@ isort:skip_file """ import builtins -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/trackable_object_graph_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/trackable_object_graph_pb2.pyi index 0c65575824a4..e786a783526a 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/trackable_object_graph_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/trackable_object_graph_pb2.pyi @@ -4,18 +4,13 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message import google.protobuf.wrappers_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/transport_options_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/transport_options_pb2.pyi index 53c27a86ecc0..e515e2968055 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/transport_options_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/transport_options_pb2.pyi @@ -4,17 +4,12 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/util/memmapped_file_system_pb2.pyi b/stubs/tensorflow/tensorflow/core/util/memmapped_file_system_pb2.pyi index 0da3ecbf492a..89c6608f6127 100644 --- a/stubs/tensorflow/tensorflow/core/util/memmapped_file_system_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/util/memmapped_file_system_pb2.pyi @@ -18,17 +18,12 @@ limitations under the License. """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/core/util/saved_tensor_slice_pb2.pyi b/stubs/tensorflow/tensorflow/core/util/saved_tensor_slice_pb2.pyi index 597ddc5fa4bc..23f69669b117 100644 --- a/stubs/tensorflow/tensorflow/core/util/saved_tensor_slice_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/util/saved_tensor_slice_pb2.pyi @@ -17,7 +17,7 @@ debugging and manual examination. """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -28,11 +28,6 @@ import tensorflow.core.framework.tensor_slice_pb2 import tensorflow.core.framework.types_pb2 import tensorflow.core.framework.versions_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/python/keras/protobuf/projector_config_pb2.pyi b/stubs/tensorflow/tensorflow/python/keras/protobuf/projector_config_pb2.pyi index dadeda2aa5e5..e034d4a52a7f 100644 --- a/stubs/tensorflow/tensorflow/python/keras/protobuf/projector_config_pb2.pyi +++ b/stubs/tensorflow/tensorflow/python/keras/protobuf/projector_config_pb2.pyi @@ -7,17 +7,12 @@ https://github.com/tensorflow/tensorboard/blob/master/tensorboard/plugins/projec """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/python/keras/protobuf/saved_metadata_pb2.pyi b/stubs/tensorflow/tensorflow/python/keras/protobuf/saved_metadata_pb2.pyi index f42202cf8ff3..391c7b0dcd24 100644 --- a/stubs/tensorflow/tensorflow/python/keras/protobuf/saved_metadata_pb2.pyi +++ b/stubs/tensorflow/tensorflow/python/keras/protobuf/saved_metadata_pb2.pyi @@ -4,18 +4,13 @@ isort:skip_file Protobuf containing the metadata for each Keras object saved in a SavedModel.""" import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message import tensorflow.python.keras.protobuf.versions_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/python/keras/protobuf/versions_pb2.pyi b/stubs/tensorflow/tensorflow/python/keras/protobuf/versions_pb2.pyi index dd5c21cbcc4c..50d547c82207 100644 --- a/stubs/tensorflow/tensorflow/python/keras/protobuf/versions_pb2.pyi +++ b/stubs/tensorflow/tensorflow/python/keras/protobuf/versions_pb2.pyi @@ -4,17 +4,12 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/tsl/protobuf/bfc_memory_map_pb2.pyi b/stubs/tensorflow/tensorflow/tsl/protobuf/bfc_memory_map_pb2.pyi index a24cd0932392..7201e2fb5da2 100644 --- a/stubs/tensorflow/tensorflow/tsl/protobuf/bfc_memory_map_pb2.pyi +++ b/stubs/tensorflow/tensorflow/tsl/protobuf/bfc_memory_map_pb2.pyi @@ -4,17 +4,12 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/tsl/protobuf/coordination_config_pb2.pyi b/stubs/tensorflow/tensorflow/tsl/protobuf/coordination_config_pb2.pyi index fcd757622079..c4855fe17c53 100644 --- a/stubs/tensorflow/tensorflow/tsl/protobuf/coordination_config_pb2.pyi +++ b/stubs/tensorflow/tensorflow/tsl/protobuf/coordination_config_pb2.pyi @@ -4,17 +4,12 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/tsl/protobuf/distributed_runtime_payloads_pb2.pyi b/stubs/tensorflow/tensorflow/tsl/protobuf/distributed_runtime_payloads_pb2.pyi index ed8dd9ae681e..b27a37c32cc3 100644 --- a/stubs/tensorflow/tensorflow/tsl/protobuf/distributed_runtime_payloads_pb2.pyi +++ b/stubs/tensorflow/tensorflow/tsl/protobuf/distributed_runtime_payloads_pb2.pyi @@ -4,17 +4,12 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/tsl/protobuf/histogram_pb2.pyi b/stubs/tensorflow/tensorflow/tsl/protobuf/histogram_pb2.pyi index 69ee0c2277e1..8e1e4be2c7e7 100644 --- a/stubs/tensorflow/tensorflow/tsl/protobuf/histogram_pb2.pyi +++ b/stubs/tensorflow/tensorflow/tsl/protobuf/histogram_pb2.pyi @@ -4,17 +4,12 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/tensorflow/tensorflow/tsl/protobuf/rpc_options_pb2.pyi b/stubs/tensorflow/tensorflow/tsl/protobuf/rpc_options_pb2.pyi index 62370eb9cc1d..0d76b7d2ea65 100644 --- a/stubs/tensorflow/tensorflow/tsl/protobuf/rpc_options_pb2.pyi +++ b/stubs/tensorflow/tensorflow/tsl/protobuf/rpc_options_pb2.pyi @@ -3,16 +3,11 @@ isort:skip_file """ import builtins -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final From f8249d7c0a88207954aa36cc2f73098df4f90bae Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 29 Feb 2024 17:19:33 +0000 Subject: [PATCH 09/21] [pre-commit.ci] auto fixes from pre-commit.com hooks --- .../tensorflow/tensorflow/core/framework/graph_pb2.pyi | 10 +++++----- .../tensorflow/core/framework/tensor_slice_pb2.pyi | 2 +- .../tensorflow/tensorflow/core/protobuf/debug_pb2.pyi | 6 +++--- .../tensorflow/core/protobuf/named_tensor_pb2.pyi | 2 +- .../tensorflow/core/protobuf/rewriter_config_pb2.pyi | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/stubs/tensorflow/tensorflow/core/framework/graph_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/graph_pb2.pyi index 0ca220f9fa1d..bc5acf98eb04 100644 --- a/stubs/tensorflow/tensorflow/core/framework/graph_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/graph_pb2.pyi @@ -41,7 +41,7 @@ class GraphDef(google.protobuf.message.Message): @property def library(self) -> tensorflow.core.framework.function_pb2.FunctionDefLibrary: """"library" provides user-defined functions. - + Naming: * library.function.name are in a flat namespace. NOTE: We may need to change it to be hierarchical to support @@ -53,14 +53,14 @@ class GraphDef(google.protobuf.message.Message): * If node[i].op is the name of one function in "library", node[i] is deemed as a function call. Otherwise, node[i].op must be a primitive operation supported by the runtime. - - + + Function call semantics: - + * The callee may start execution as soon as some of its inputs are ready. The caller may want to use Tuple() mechanism to ensure all inputs are ready in the same time. - + * The consumer of return values may start executing as soon as the return values the consumer depends on are ready. The consumer may want to use Tuple() mechanism to ensure the diff --git a/stubs/tensorflow/tensorflow/core/framework/tensor_slice_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/tensor_slice_pb2.pyi index d938d4101f8a..640fa1c6f47b 100644 --- a/stubs/tensorflow/tensorflow/core/framework/tensor_slice_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/tensor_slice_pb2.pyi @@ -46,7 +46,7 @@ class TensorSliceProto(google.protobuf.message.Message): @property def extent(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___TensorSliceProto.Extent]: """Extent of the slice in all tensor dimensions. - + Must have one entry for each of the dimension of the tensor that this slice belongs to. The order of sizes is the same as the order of dimensions in the TensorShape. diff --git a/stubs/tensorflow/tensorflow/core/protobuf/debug_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/debug_pb2.pyi index d5b0b7164ea6..0280d3bbe3f9 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/debug_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/debug_pb2.pyi @@ -44,7 +44,7 @@ class DebugTensorWatch(google.protobuf.message.Message): @property def debug_urls(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: """URL(s) for debug targets(s). - + Supported URL formats are: - file:///foo/tfdbg_dump: Writes out Event content to file /foo/tfdbg_dump. Assumes all directories can be created if they don't @@ -53,10 +53,10 @@ class DebugTensorWatch(google.protobuf.message.Message): service running at localhost:11011 with the event. - memcbk:///event_key: Routes tensors to clients using the callback registered with the DebugCallbackRegistry for event_key. - + Each debug op listed in debug_ops will publish its output tensor (debug signal) to all URLs in debug_urls. - + N.B. Session::Run() supports concurrent invocations of the same inputs (feed keys), outputs and target nodes. If such concurrent invocations are to be debugged, the callers of Session::Run() must use distinct diff --git a/stubs/tensorflow/tensorflow/core/protobuf/named_tensor_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/named_tensor_pb2.pyi index d649783ff22d..6c9841e14653 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/named_tensor_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/named_tensor_pb2.pyi @@ -25,7 +25,7 @@ class NamedTensorProto(google.protobuf.message.Message): def tensor(self) -> tensorflow.core.framework.tensor_pb2.TensorProto: """The client can populate a TensorProto using a tensorflow::Tensor`, or directly using the protobuf field accessors. - + The client specifies whether the returned tensor values should be filled tensor fields (float_val, int_val, etc.) or encoded in a compact form in tensor.tensor_content. diff --git a/stubs/tensorflow/tensorflow/core/protobuf/rewriter_config_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/rewriter_config_pb2.pyi index 883a7d707ea5..9bf638aa42bd 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/rewriter_config_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/rewriter_config_pb2.pyi @@ -420,13 +420,13 @@ class RewriterConfig(google.protobuf.message.Message): """If non-empty, will use this as an alternative way to specify a list of optimizations to turn on and the order of the optimizations (replacing the meta-optimizer). - + Of the RewriterConfig options, only the AutoParallel configuration options (the auto_parallel field) apply to manually requested optimization passes ("autoparallel"). Memory optimization passes ("memory") invoked here are not configurable (in contrast to memory optimization passes through the meta-optimizer) and act only on manual op annotations. - + Custom optimizers (see custom_optimizers) that are not part of this schedule will be run after - in the order that they were specified. """ From ccf8d468bee7efdc658fc1abb402c3332a6a2b68 Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 29 Feb 2024 12:23:33 -0500 Subject: [PATCH 10/21] Also apply to google/protobuf --- scripts/generate_proto_stubs.sh | 3 ++- stubs/protobuf/google/protobuf/any_pb2.pyi | 7 +------ stubs/protobuf/google/protobuf/api_pb2.pyi | 7 +------ stubs/protobuf/google/protobuf/duration_pb2.pyi | 7 +------ stubs/protobuf/google/protobuf/empty_pb2.pyi | 8 ++------ stubs/protobuf/google/protobuf/field_mask_pb2.pyi | 7 +------ stubs/protobuf/google/protobuf/source_context_pb2.pyi | 7 +------ stubs/protobuf/google/protobuf/timestamp_pb2.pyi | 7 +------ stubs/protobuf/google/protobuf/wrappers_pb2.pyi | 7 +------ 9 files changed, 11 insertions(+), 49 deletions(-) diff --git a/scripts/generate_proto_stubs.sh b/scripts/generate_proto_stubs.sh index 011b1e8d0c7a..806f197607b4 100755 --- a/scripts/generate_proto_stubs.sh +++ b/scripts/generate_proto_stubs.sh @@ -73,7 +73,8 @@ PROTO_FILES=$(grep "GenProto.*google" $PYTHON_PROTOBUF_DIR/python/setup.py | \ # shellcheck disable=SC2086 protoc_install/bin/protoc --proto_path="$PYTHON_PROTOBUF_DIR/src" --mypy_out="relax_strict_optional_primitives:$REPO_ROOT/stubs/protobuf" $PROTO_FILES -ruff check "$REPO_ROOT/stubs/protobuf" --fix-only +# --unsafe-fixes to apply outdated-version-block (UP036) +ruff check "$REPO_ROOT/stubs/protobuf" --fix-only --unsafe-fixes black "$REPO_ROOT/stubs/protobuf" sed --in-place="" \ diff --git a/stubs/protobuf/google/protobuf/any_pb2.pyi b/stubs/protobuf/google/protobuf/any_pb2.pyi index 1a9040cd5cfc..e9108a01f236 100644 --- a/stubs/protobuf/google/protobuf/any_pb2.pyi +++ b/stubs/protobuf/google/protobuf/any_pb2.pyi @@ -32,17 +32,12 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ import builtins -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.well_known_types import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/protobuf/google/protobuf/api_pb2.pyi b/stubs/protobuf/google/protobuf/api_pb2.pyi index f4365a0e4dff..342c9307101d 100644 --- a/stubs/protobuf/google/protobuf/api_pb2.pyi +++ b/stubs/protobuf/google/protobuf/api_pb2.pyi @@ -33,7 +33,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -41,11 +41,6 @@ import google.protobuf.message import google.protobuf.source_context_pb2 import google.protobuf.type_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/protobuf/google/protobuf/duration_pb2.pyi b/stubs/protobuf/google/protobuf/duration_pb2.pyi index 681097d80e34..a97b8d9251a8 100644 --- a/stubs/protobuf/google/protobuf/duration_pb2.pyi +++ b/stubs/protobuf/google/protobuf/duration_pb2.pyi @@ -32,17 +32,12 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ import builtins -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.well_known_types import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/protobuf/google/protobuf/empty_pb2.pyi b/stubs/protobuf/google/protobuf/empty_pb2.pyi index 2f1c614527bf..f0f42ceb20f2 100644 --- a/stubs/protobuf/google/protobuf/empty_pb2.pyi +++ b/stubs/protobuf/google/protobuf/empty_pb2.pyi @@ -31,16 +31,12 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ -import sys + +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/protobuf/google/protobuf/field_mask_pb2.pyi b/stubs/protobuf/google/protobuf/field_mask_pb2.pyi index 07012bab5bca..60d15e8765b0 100644 --- a/stubs/protobuf/google/protobuf/field_mask_pb2.pyi +++ b/stubs/protobuf/google/protobuf/field_mask_pb2.pyi @@ -33,18 +33,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.internal.well_known_types import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/protobuf/google/protobuf/source_context_pb2.pyi b/stubs/protobuf/google/protobuf/source_context_pb2.pyi index e11d903038f6..b93ab58d0251 100644 --- a/stubs/protobuf/google/protobuf/source_context_pb2.pyi +++ b/stubs/protobuf/google/protobuf/source_context_pb2.pyi @@ -32,16 +32,11 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ import builtins -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/protobuf/google/protobuf/timestamp_pb2.pyi b/stubs/protobuf/google/protobuf/timestamp_pb2.pyi index f5bfbc594c92..916066f9af0f 100644 --- a/stubs/protobuf/google/protobuf/timestamp_pb2.pyi +++ b/stubs/protobuf/google/protobuf/timestamp_pb2.pyi @@ -32,17 +32,12 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ import builtins -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.well_known_types import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final diff --git a/stubs/protobuf/google/protobuf/wrappers_pb2.pyi b/stubs/protobuf/google/protobuf/wrappers_pb2.pyi index 9cc4a3e8fedb..e3d3682d7edb 100644 --- a/stubs/protobuf/google/protobuf/wrappers_pb2.pyi +++ b/stubs/protobuf/google/protobuf/wrappers_pb2.pyi @@ -12,16 +12,11 @@ These wrappers have no meaningful use within a map or a oneof since individual entries of a map or fields of a oneof can already detect presence. """ import builtins -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.message -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final From f95f0c5c402885b1fe13a61cd4da9e30b578c266 Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 29 Feb 2024 12:45:20 -0500 Subject: [PATCH 11/21] s2clientprotocol --- stubs/s2clientprotocol/s2clientprotocol/query_pb2.pyi | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/stubs/s2clientprotocol/s2clientprotocol/query_pb2.pyi b/stubs/s2clientprotocol/s2clientprotocol/query_pb2.pyi index e954e46118e1..53553c043bbc 100644 --- a/stubs/s2clientprotocol/s2clientprotocol/query_pb2.pyi +++ b/stubs/s2clientprotocol/s2clientprotocol/query_pb2.pyi @@ -4,7 +4,7 @@ isort:skip_file """ import builtins import collections.abc -import sys +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -12,11 +12,6 @@ import google.protobuf.message import s2clientprotocol.common_pb2 import s2clientprotocol.error_pb2 -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing_extensions.final From 10bae4f37763a4dab113683b691cdb255bd0bee7 Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 29 Feb 2024 12:59:06 -0500 Subject: [PATCH 12/21] Safer script change --- scripts/generate_proto_stubs.sh | 4 ++-- scripts/sync_tensorflow_protobuf_stubs.sh | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/generate_proto_stubs.sh b/scripts/generate_proto_stubs.sh index 806f197607b4..0e10aa2b4867 100755 --- a/scripts/generate_proto_stubs.sh +++ b/scripts/generate_proto_stubs.sh @@ -73,8 +73,8 @@ PROTO_FILES=$(grep "GenProto.*google" $PYTHON_PROTOBUF_DIR/python/setup.py | \ # shellcheck disable=SC2086 protoc_install/bin/protoc --proto_path="$PYTHON_PROTOBUF_DIR/src" --mypy_out="relax_strict_optional_primitives:$REPO_ROOT/stubs/protobuf" $PROTO_FILES -# --unsafe-fixes to apply outdated-version-block (UP036) -ruff check "$REPO_ROOT/stubs/protobuf" --fix-only --unsafe-fixes +ruff check "$REPO_ROOT/stubs/protobuf" --fix-only +ruff check "$REPO_ROOT/stubs/protobuf" --fix-only --select=UP036 --unsafe-fixes black "$REPO_ROOT/stubs/protobuf" sed --in-place="" \ diff --git a/scripts/sync_tensorflow_protobuf_stubs.sh b/scripts/sync_tensorflow_protobuf_stubs.sh index 943e56920999..0ffb65b53fb6 100755 --- a/scripts/sync_tensorflow_protobuf_stubs.sh +++ b/scripts/sync_tensorflow_protobuf_stubs.sh @@ -62,7 +62,8 @@ rm tensorflow/compiler/xla/service/hlo_execution_profile_data_pb2.pyi \ tensorflow/core/util/example_proto_fast_parsing_test_pb2.pyi # --unsafe-fixes to apply outdated-version-block (UP036) -ruff check "$REPO_ROOT/stubs/tensorflow/tensorflow" --fix-only --unsafe-fixes +ruff check "$REPO_ROOT/stubs/tensorflow/tensorflow" --fix-only +ruff check "$REPO_ROOT/stubs/protobuf" --fix-only --select=UP036 --unsafe-fixes black "$REPO_ROOT/stubs/tensorflow/tensorflow" sed --in-place="" \ From d432e5caffc6c934f47705856f0ab15a9f1d0fd8 Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 29 Feb 2024 13:09:35 -0500 Subject: [PATCH 13/21] Apply suggestions from code review Co-authored-by: Alex Waygood --- scripts/sync_tensorflow_protobuf_stubs.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/sync_tensorflow_protobuf_stubs.sh b/scripts/sync_tensorflow_protobuf_stubs.sh index 0ffb65b53fb6..3e4a355e0d67 100755 --- a/scripts/sync_tensorflow_protobuf_stubs.sh +++ b/scripts/sync_tensorflow_protobuf_stubs.sh @@ -61,7 +61,6 @@ rm tensorflow/compiler/xla/service/hlo_execution_profile_data_pb2.pyi \ tensorflow/core/protobuf/worker_service_pb2.pyi \ tensorflow/core/util/example_proto_fast_parsing_test_pb2.pyi -# --unsafe-fixes to apply outdated-version-block (UP036) ruff check "$REPO_ROOT/stubs/tensorflow/tensorflow" --fix-only ruff check "$REPO_ROOT/stubs/protobuf" --fix-only --select=UP036 --unsafe-fixes black "$REPO_ROOT/stubs/tensorflow/tensorflow" From 32f597e2b52c805ba695e2a7754fafd161f53cc0 Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 29 Feb 2024 15:43:01 -0500 Subject: [PATCH 14/21] Update stdlib/builtins.pyi --- stdlib/builtins.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index fed80967659b..6b54f759c5e7 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -98,7 +98,6 @@ class object: __annotations__: dict[str, Any] @property def __class__(self) -> type[Self]: ... - # Ignore errors about type mismatch between property getter and setter @__class__.setter def __class__(self, __type: type[object]) -> None: ... def __init__(self) -> None: ... From a3b0e69f0f9c35f169c556075ddd177577b5912d Mon Sep 17 00:00:00 2001 From: Avasam Date: Sat, 2 Mar 2024 13:16:55 -0500 Subject: [PATCH 15/21] Updated local ruff and re-run --- stubs/WebOb/@tests/test_cases/check_wsgify.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/WebOb/@tests/test_cases/check_wsgify.py b/stubs/WebOb/@tests/test_cases/check_wsgify.py index ec4b01dd04ce..aa33e9ad1fdd 100644 --- a/stubs/WebOb/@tests/test_cases/check_wsgify.py +++ b/stubs/WebOb/@tests/test_cases/check_wsgify.py @@ -15,8 +15,8 @@ def __call__(self, request: Request) -> str: env: WSGIEnvironment = {} -start_response: StartResponse = lambda x, y, z=None: lambda b: None -application: WSGIApplication = lambda e, s: [b""] +start_response: StartResponse = lambda x, y, z=None: lambda b: None # noqa: E731 +application: WSGIApplication = lambda e, s: [b""] # noqa: E731 request: Request = Request(env) x = App() From b916e8107f6ae0e10bfb28ef27a5d8b4af4e1f6a Mon Sep 17 00:00:00 2001 From: Avasam Date: Sun, 3 Mar 2024 18:20:28 -0500 Subject: [PATCH 16/21] Add RUF100 (unused-noqa) to test_cases --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dc4bc138b4f1..1642feb0062a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,7 +25,7 @@ repos: # Very few rules are useful to run on our test cases; # we explicitly enumerate them here: name: Run ruff on the test cases - args: ["--exit-non-zero-on-fix", "--select=FA,I", "--no-force-exclude", "--unsafe-fixes"] + args: ["--exit-non-zero-on-fix", "--select=FA,I,RUF100", "--no-force-exclude", "--unsafe-fixes"] files: '.*test_cases/.+\.py$' - repo: https://github.com/psf/black-pre-commit-mirror rev: 24.1.1 # must match requirements-tests.txt From 532ba40295b1506a5643247f22780fdd3334cb50 Mon Sep 17 00:00:00 2001 From: Avasam Date: Sun, 3 Mar 2024 18:24:43 -0500 Subject: [PATCH 17/21] Post-merge fixes --- stubs/WebOb/@tests/test_cases/check_wsgify.py | 6 +++--- test_cases/stdlib/builtins/check_list.py | 3 +-- test_cases/stdlib/typing/check_all.py | 8 ++++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/stubs/WebOb/@tests/test_cases/check_wsgify.py b/stubs/WebOb/@tests/test_cases/check_wsgify.py index aa33e9ad1fdd..bc9f2a9deb70 100644 --- a/stubs/WebOb/@tests/test_cases/check_wsgify.py +++ b/stubs/WebOb/@tests/test_cases/check_wsgify.py @@ -1,7 +1,7 @@ from __future__ import annotations from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment -from collections.abc import Iterable # noqa: F401 +from collections.abc import Iterable from typing_extensions import assert_type from webob.dec import _AnyResponse, wsgify @@ -15,8 +15,8 @@ def __call__(self, request: Request) -> str: env: WSGIEnvironment = {} -start_response: StartResponse = lambda x, y, z=None: lambda b: None # noqa: E731 -application: WSGIApplication = lambda e, s: [b""] # noqa: E731 +start_response: StartResponse = lambda x, y, z=None: lambda b: None +application: WSGIApplication = lambda e, s: [b""] request: Request = Request(env) x = App() diff --git a/test_cases/stdlib/builtins/check_list.py b/test_cases/stdlib/builtins/check_list.py index 40c460727bed..4113f5c66182 100644 --- a/test_cases/stdlib/builtins/check_list.py +++ b/test_cases/stdlib/builtins/check_list.py @@ -15,8 +15,7 @@ def asd(self) -> int: return 2 -# Testing for concatenation -combined = [Foo()] + [Bar()] # noqa: RUF005 +combined = [Foo()] + [Bar()] assert_type(combined, List[Union[Foo, Bar]]) for item in combined: assert_type(item.asd(), int) diff --git a/test_cases/stdlib/typing/check_all.py b/test_cases/stdlib/typing/check_all.py index 3c3f56813c69..44eb548e04a9 100644 --- a/test_cases/stdlib/typing/check_all.py +++ b/test_cases/stdlib/typing/check_all.py @@ -5,10 +5,10 @@ from __future__ import annotations import sys -from typing import * # noqa: F403 -from zipfile import * # noqa: F403 +from typing import * +from zipfile import * if sys.version_info >= (3, 9): - x: Annotated[int, 42] # noqa: F405 + x: Annotated[int, 42] -p: Path # noqa: F405 +p: Path From 1066021bc46d554ba9c2f09c0f01eb24bf99c56f Mon Sep 17 00:00:00 2001 From: Avasam Date: Sun, 3 Mar 2024 18:49:58 -0500 Subject: [PATCH 18/21] Update pyproject.toml Co-authored-by: Alex Waygood --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 84fe56f3db9c..76b663aee98b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,6 +32,8 @@ exclude = [ # are invoked via separate runs of ruff in pre-commit: # see our .pre-commit-config.yaml file for details exclude = ["**/test_cases/**/*.py"] +# We still use flake8-pyi and flake8-noqa to check these (see .flake8 config file); +# tell ruff not to flag these as e.g. "unused noqa comments" external = ["F821", "NQA", "Y"] extend-select = [ "B", # flake8-bugbear From e03f0fdb8de31c3c9079b6b0d78591609614e165 Mon Sep 17 00:00:00 2001 From: Avasam Date: Sun, 3 Mar 2024 19:37:04 -0500 Subject: [PATCH 19/21] Use select instead of extend-select --- pyproject.toml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 84fe56f3db9c..e2d0578d90c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,12 +33,16 @@ exclude = [ # see our .pre-commit-config.yaml file for details exclude = ["**/test_cases/**/*.py"] external = ["F821", "NQA", "Y"] -extend-select = [ +select = [ "B", # flake8-bugbear "FA", # flake8-future-annotations "I", # isort "RUF", # Ruff-specific and unused-noqa "UP", # pyupgrade + # Flake8 base rules + "E", # pycodestyle Error + "F", # Pyflakes + "W", # pycodestyle Warning # PYI: only enable rules that always autofix, avoids duplicate # noqa with flake8-pyi # See https://github.com/plinss/flake8-noqa/issues/22 "PYI009", # use `...`, not `pass`, in empty class bodies @@ -53,6 +57,15 @@ extend-select = [ "PYI058", # use `Iterator` as the return type for `__iter__` methods ] ignore = [ + ### + # Rules that can conflict with the formatter (Black) + # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules + ### + "E111", # indentation-with-invalid-multiple + "E114", # indentation-with-invalid-multiple-comment + "E117", # over-indented + "E501", # line-too-long, allow comments over line-length + "W191", # tab-indentation ### # Rules we don't want or don't agree with ### From ddccce305f843e6c5cb8ddd97c4525d6d22c6cf6 Mon Sep 17 00:00:00 2001 From: Avasam Date: Sun, 3 Mar 2024 21:56:20 -0500 Subject: [PATCH 20/21] Improve comments --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1104fa30102d..47ac44934cb3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,7 +66,6 @@ ignore = [ "E111", # indentation-with-invalid-multiple "E114", # indentation-with-invalid-multiple-comment "E117", # over-indented - "E501", # line-too-long, allow comments over line-length "W191", # tab-indentation ### # Rules we don't want or don't agree with @@ -93,7 +92,8 @@ ignore = [ "F403", # `from . import *` used; unable to detect undefined names # False positives in stubs "F821", # Undefined name: https://github.com/astral-sh/ruff/issues/3011 - # FIXME: Fix these in stubs, then remove these entries + # Stubs can sometimes re-export entire modules. + # Issues with using a star-imported name will be caught by type-checkers. "F405", # may be undefined, or defined from star imports ] From 4530a0bf3728620dfcd6df5a71f659cfc4795d2c Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 4 Mar 2024 00:09:23 -0500 Subject: [PATCH 21/21] Update pyproject.toml --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 47ac44934cb3..fa3befac8549 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,6 +81,7 @@ ignore = [ # Ruff doesn't support multi-file analysis yet: https://github.com/astral-sh/ruff/issues/5295 "RUF013", # PEP 484 prohibits implicit `Optional` ] + [tool.ruff.lint.per-file-ignores] "*.pyi" = [ # Most flake8-bugbear rules don't apply for third-party stubs like typeshed.