Support subset of tagged union strategy
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Start at the configure_tagged_union entry point and reproduce the reported Foo and Bar examples with cattrs 23.1.0.dev0. Trace how configured tagged unions are matched and add coverage for a subset such as A | B; done means Bar(A(1)) uses the tagged-union strategy without requiring every combination to be configured.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
- cattrs version: 23.1.0.dev0
- Python version: 3.11.1
- Operating System: Manjaro KDE
Description
Subsets of tagged unions should also be able to use the configured strategy.
What I Did
import attrs
import cattrs
from cattrs.strategies import configure_tagged_union
@attrs.define
class A:
x: int
@attrs.define
class B:
x: str
@attrs.define
class C:
x: list[float]
@attrs.define
class Foo:
y: A | B | C
@attrs.define
class Bar:
y: A | B
c = cattrs.Converter()
configure_tagged_union(A | B | C, converter=c)
c.unstructure(Foo(A(1))) # {'y': {'x': 1, '_type': 'A'}}
c.unstructure(Bar(A(1))) # {'y': {'x': 1}}
Because Bar uses only A | B, and I've only configured A | B | C, it doesn't use the strategy.
I think it should be possible to use the strategy for A | B | C when I only have A | B, a subset of it. If not by default, this should be a configurable option, like configure_tagged_union(A | B | C, converter=c, allow_subset=True).
Otherwise, I'd need to repeatedly define all possible combinations of A, B, and C, like:
configure_tagged_union(A | B, converter=c)
configure_tagged_union(A | C, converter=c)
configure_tagged_union(B | C, converter=c)
configure_tagged_union(A | B | C, converter=c)
- Ngôn ngữ chính
- Python
- Star
- 1.1k
- Fork
- 168
- Merge trung bình
- 2 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 7
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của python-attrs/cattrs
-
decimal.Decimal not handled in preconf converters (json, pyyaml)Có thể đã có người làm @Binilkks đã nhận 106 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
python-attrs/cattrs#761 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
python-attrs/cattrs#513 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 85/100
python-attrs/cattrs#774 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
python-attrs/cattrs#746 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Implement a strategy to resolve natively Sequence[X] | YCó thể đã có người làm @jhominal đã nhận 182 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
python-attrs/cattrs#743 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của python-attrs/cattrs
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 83/100
PedestrianDynamics/pyFDS-Evac#766 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Markdown tables render as literal text in 3 example files (missing blank line before header)Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 91/100
alchaincyf/nuwa-skill#86 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Docs Needs Triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
pandas-dev/pandas#71055 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: graphify reads files that git's global ignore file hidesCó thể đã có người làm @smngvlkz đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Graphify-Labs/graphify#4335 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày