protocolbuffers / protobuf

Protocol Buffers - Google's data interchange format
http://protobuf.dev
Other
65.25k stars 15.45k forks source link

Python: global constants are annotated with ClassVar for extends blocks. #13700

Open tmccombs opened 1 year ago

tmccombs commented 1 year ago

What version of protobuf and what language are you using? Version: libprotoc 23.4 Language: Python

What operating system (Linux, Windows, ...) and version? Archlinux

What runtime / compiler are you using (e.g., python version or gcc version)

python 3.11.3

What did you do? Steps to reproduce the behavior:

Create a protbuf file like the following:

syntax  = "proto3";

package test;

import "google/protobuf/descriptor.proto";

extend google.protobuf.MessageOptions {
  optional string version_msg = 50000;
}

then run protoc --pyil_out=. test.proto

This results in the following code:

from google.protobuf import descriptor_pb2 as _descriptor_pb2
from google.protobuf import descriptor as _descriptor
from typing import ClassVar as _ClassVar

DESCRIPTOR: _descriptor.FileDescriptor
MY_VERSION_FIELD_NUMBER: _ClassVar[int]
my_version: _descriptor.FieldDescriptor

What did you expect to see

MY_VERSION_FIELD_NUMBER should be typed as int

What did you see instead?

MY_VERSION_FIELD_NUMBER is typed as ClassVar[int] python type checkers such as mypy and pyright complain about ClassVar being used outside of a class.

github-actions[bot] commented 9 months ago

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago.

tmccombs commented 9 months ago

This should remain active. I think. I'm not entirely sure what is implied by the "inactive" tag.

github-actions[bot] commented 6 months ago

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago.

github-actions[bot] commented 6 months ago

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.

This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.

tmccombs commented 6 months ago

This is still a problem. can it be re-opened?

LuckySting commented 3 months ago

Run into this problem too, please, re-open issue!

dniwelive commented 3 months ago

@anandolee @zhangskz Could you reopen the issue and share your thoughts on it? It looks abandoned for almost a year.

GoncharovArtyom commented 3 months ago

+1

zhangskz commented 3 months ago

@anandolee Can you take a look?

github-actions[bot] commented 5 days ago

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago. This issue will be closed and archived after 14 additional days without activity.

dniwelive commented 5 days ago

@anandolee any updates here?