danielgtaylor / danielgtaylor/python-betterproto
Create `__all__` to explicitly export only the important parts
- Ngôn ngữ chính
- Python
- Star
- 1.8k
- Fork
- 234
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
Currently, it generates the following:
```py
# Generated by the protocol buffer compiler. DO NOT EDIT!
# sources: example.proto
# plugin: python-betterproto
from dataclasses import dataclass
import betterproto
@dataclass
class Greeting(betterproto.Message):
"""Greeting represents a message you can tell a user."""
message: str = betterproto.string_field(1)
```
If you try to import from it, you'll get suggestions for importing `dataclass`, `betterproto` and `Greeting`.
Those first two, though, aren't meant to be re-exported there, only `Greeting` is supposed to be importable.
By generating with an `__all__ = ["Greeting"]`, Python would know that the only thing it's supposed to import is `Greeting`:
```py
# Generated by the protocol buffer compiler. DO NOT EDIT!
# sources: example.proto
# plugin: python-betterproto
__all__ = ["Greeting"]
from dataclasses import dataclass
import betterproto
@dataclass
class Greeting(betterproto.Message):
"""Greeting represents a message you can tell a user."""
message: str = betterproto.string_field(1)
```
https://docs.python.org/3/tutorial/modules.html#importing-from-a-package
https://pep8.org/#module-level-dunder-names
Hướng dẫn đóng góp
Hướng nghiên cứu
Issue này nhắm đến module Python được sinh ra và các export công khai của nó. Hãy xác định entry point của generator dùng để tạo module này, sau đó kiểm tra mọi test hoặc fixture hiện có của generator trước khi thay đổi output. Công việc được xem là hoàn tất khi các module được sinh ra chứa một __all__ chỉ liệt kê các symbol message và service được dự định, đồng thời các test bao quát những import tạo ra từ đó.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- tooling
- Loại issue
- Tính năng
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100