Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8823820

Browse files
AvasamAlexWaygood
andauthored
Add pyupgrade check outdated-version-block (UP036) (#11509)
Co-authored-by: Alex Waygood <[email protected]>
1 parent 2116158 commit 8823820

68 files changed

Lines changed: 68 additions & 395 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pyproject.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ ignore = [
5757
# B033 could be slightly useful but Ruff doesn't have per-file select
5858
"B", # flake8-bugbear
5959
]
60-
# Generated protobuf files:
61-
# TODO: Re-run sync_tensorflow_protobuf_stubs.sh with this rule enabled to remove this entry
62-
"*_pb2.pyi" = [
63-
"UP036", # Version block is outdated for minimum Python version
64-
]
6560

6661
[tool.ruff.lint.isort]
6762
split-on-trailing-comma = false

scripts/generate_proto_stubs.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ PROTO_FILES=$(grep "GenProto.*google" $PYTHON_PROTOBUF_DIR/python/setup.py | \
7474
protoc_install/bin/protoc --proto_path="$PYTHON_PROTOBUF_DIR/src" --mypy_out="relax_strict_optional_primitives:$REPO_ROOT/stubs/protobuf" $PROTO_FILES
7575

7676
ruff check "$REPO_ROOT/stubs/protobuf" --fix-only
77+
ruff check "$REPO_ROOT/stubs/protobuf" --fix-only --select=UP036 --unsafe-fixes
7778
black "$REPO_ROOT/stubs/protobuf"
7879

7980
sed --in-place="" \

scripts/sync_tensorflow_protobuf_stubs.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ rm tensorflow/compiler/xla/service/hlo_execution_profile_data_pb2.pyi \
6262
tensorflow/core/util/example_proto_fast_parsing_test_pb2.pyi
6363

6464
ruff check "$REPO_ROOT/stubs/tensorflow/tensorflow" --fix-only
65+
ruff check "$REPO_ROOT/stubs/protobuf" --fix-only --select=UP036 --unsafe-fixes
6566
black "$REPO_ROOT/stubs/tensorflow/tensorflow"
6667

6768
sed --in-place="" \

stubs/protobuf/google/protobuf/any_pb2.pyi

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,12 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3232
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333
"""
3434
import builtins
35-
import sys
35+
import typing as typing_extensions
3636

3737
import google.protobuf.descriptor
3838
import google.protobuf.internal.well_known_types
3939
import google.protobuf.message
4040

41-
if sys.version_info >= (3, 8):
42-
import typing as typing_extensions
43-
else:
44-
import typing_extensions
45-
4641
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
4742

4843
@typing_extensions.final

stubs/protobuf/google/protobuf/api_pb2.pyi

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333
"""
3434
import builtins
3535
import collections.abc
36-
import sys
36+
import typing as typing_extensions
3737

3838
import google.protobuf.descriptor
3939
import google.protobuf.internal.containers
4040
import google.protobuf.message
4141
import google.protobuf.source_context_pb2
4242
import google.protobuf.type_pb2
4343

44-
if sys.version_info >= (3, 8):
45-
import typing as typing_extensions
46-
else:
47-
import typing_extensions
48-
4944
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
5045

5146
@typing_extensions.final

stubs/protobuf/google/protobuf/duration_pb2.pyi

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,12 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3232
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333
"""
3434
import builtins
35-
import sys
35+
import typing as typing_extensions
3636

3737
import google.protobuf.descriptor
3838
import google.protobuf.internal.well_known_types
3939
import google.protobuf.message
4040

41-
if sys.version_info >= (3, 8):
42-
import typing as typing_extensions
43-
else:
44-
import typing_extensions
45-
4641
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
4742

4843
@typing_extensions.final

stubs/protobuf/google/protobuf/empty_pb2.pyi

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,12 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3131
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3232
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333
"""
34-
import sys
34+
35+
import typing as typing_extensions
3536

3637
import google.protobuf.descriptor
3738
import google.protobuf.message
3839

39-
if sys.version_info >= (3, 8):
40-
import typing as typing_extensions
41-
else:
42-
import typing_extensions
43-
4440
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
4541

4642
@typing_extensions.final

stubs/protobuf/google/protobuf/field_mask_pb2.pyi

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333
"""
3434
import builtins
3535
import collections.abc
36-
import sys
36+
import typing as typing_extensions
3737

3838
import google.protobuf.descriptor
3939
import google.protobuf.internal.containers
4040
import google.protobuf.internal.well_known_types
4141
import google.protobuf.message
4242

43-
if sys.version_info >= (3, 8):
44-
import typing as typing_extensions
45-
else:
46-
import typing_extensions
47-
4843
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
4944

5045
@typing_extensions.final

stubs/protobuf/google/protobuf/source_context_pb2.pyi

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,11 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3232
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333
"""
3434
import builtins
35-
import sys
35+
import typing as typing_extensions
3636

3737
import google.protobuf.descriptor
3838
import google.protobuf.message
3939

40-
if sys.version_info >= (3, 8):
41-
import typing as typing_extensions
42-
else:
43-
import typing_extensions
44-
4540
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
4641

4742
@typing_extensions.final

stubs/protobuf/google/protobuf/timestamp_pb2.pyi

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,12 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3232
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333
"""
3434
import builtins
35-
import sys
35+
import typing as typing_extensions
3636

3737
import google.protobuf.descriptor
3838
import google.protobuf.internal.well_known_types
3939
import google.protobuf.message
4040

41-
if sys.version_info >= (3, 8):
42-
import typing as typing_extensions
43-
else:
44-
import typing_extensions
45-
4641
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
4742

4843
@typing_extensions.final

0 commit comments

Comments
 (0)