- Sort Score
- Num 10 results
- Language All
Results 1 - 10 of 107 for union (0.02 seconds)
-
docs/zh/docs/advanced/advanced-python-types.md
# 高级 Python 类型 { #advanced-python-types } 这里有一些在使用 Python 类型时可能有用的额外想法。 ## 使用 `Union` 或 `Optional` { #using-union-or-optional } 如果你的代码因为某些原因不能使用 `|`,例如它不是在类型注解里,而是在 `response_model=` 之类的参数中,那么你可以使用 `typing` 中的 `Union` 来代替竖线(`|`)。 例如,你可以声明某个值可以是 `str` 或 `None`: ```python from typing import Union def say_hi(name: Union[str, None]): print(f"Hi {name}!") ``` `typing` 也提供了一个声明“可能为 `None`”的快捷方式:`Optional`。Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Feb 13 13:37:57 GMT 2026 - 2K bytes - Click Count (0) -
docs/ja/docs/advanced/advanced-python-types.md
# 高度な Python の型 { #advanced-python-types } Python の型を扱うときに役立つ追加のアイデアをいくつか紹介します。 ## `Union` または `Optional` の利用 { #using-union-or-optional } 何らかの理由で `|` が使えない場合、たとえば型アノテーションではなく `response_model=` のような場所では、縦棒(`|`)の代わりに `typing` の `Union` を使えます。 例えば、`str` または `None` になり得ることを宣言できます: ```python from typing import Union def say_hi(name: Union[str, None]): print(f"Hi {name}!") ```Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Feb 13 15:24:30 GMT 2026 - 2.4K bytes - Click Count (0) -
android/guava-tests/test/com/google/common/collect/SetViewTest.java
assertMinSize(union(emptySet(), emptySet()), 0); assertMinSize(union(setSize(2), setSize(3)), 3); assertMinSize(union(setSize(3), setSize(2)), 3); assertMinSize(union(setSizeRange(10, 20), setSizeRange(11, 12)), 11); assertMinSize(union(setSizeRange(11, 12), setSizeRange(10, 20)), 11); } public void testUnion_maxSize() { assertMaxSize(union(emptySet(), emptySet()), 0);
Created: Fri Apr 03 12:43:13 GMT 2026 - Last Modified: Thu Aug 07 16:05:33 GMT 2025 - 29.9K bytes - Click Count (0) -
docs/en/docs/tutorial/extra-models.md
## `Union` or `anyOf` { #union-or-anyof } You can declare a response to be the `Union` of two or more types, that means, that the response would be any of them. It will be defined in OpenAPI with `anyOf`. To do that, use the standard Python type hint [`typing.Union`](https://docs.python.org/3/library/typing.html#typing.Union): /// noteCreated: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Mar 05 18:13:19 GMT 2026 - 6.7K bytes - Click Count (0) -
fastapi/_compat/shared.py
return True origin = get_origin(annotation) if origin is Union or origin is UnionType: for arg in get_args(annotation): if lenient_issubclass(arg, UploadFile): return True return False def is_bytes_sequence_annotation(annotation: Any) -> bool: origin = get_origin(annotation) if origin is Union or origin is UnionType: at_least_one = FalseCreated: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Wed Feb 11 18:32:12 GMT 2026 - 6.9K bytes - Click Count (0) -
internal/config/lambda/event/targetidset.go
maps.Copy(setCopy, set) return setCopy } // add - adds TargetID to the set. func (set TargetIDSet) add(targetID TargetID) { set[targetID] = struct{}{} } // Union - returns union with given set as new set. func (set TargetIDSet) Union(sset TargetIDSet) TargetIDSet { nset := set.Clone() for k := range sset { nset.add(k) } return nset }
Created: Sun Apr 05 19:28:12 GMT 2026 - Last Modified: Fri Aug 29 02:39:48 GMT 2025 - 1.9K bytes - Click Count (0) -
docs/en/docs/advanced/advanced-python-types.md
## Using `Union` or `Optional` { #using-union-or-optional } If your code for some reason can't use `|`, for example if it's not in a type annotation but in something like `response_model=`, instead of using the vertical bar (`|`) you can use `Union` from `typing`. For example, you could declare that something could be a `str` or `None`: ```python from typing import Union def say_hi(name: Union[str, None]):Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Wed Feb 11 18:32:12 GMT 2026 - 2K bytes - Click Count (0) -
tests/test_response_model_as_return_annotation.py
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Tue Feb 17 09:59:14 GMT 2026 - 50.3K bytes - Click Count (0) -
docs/ko/docs/advanced/advanced-python-types.md
Python 타입을 다룰 때 유용할 수 있는 몇 가지 추가 아이디어를 소개합니다. ## `Union` 또는 `Optional` 사용 { #using-union-or-optional } 어떤 이유로 코드에서 `|`를 사용할 수 없다면, 예를 들어 타입 어노테이션이 아니라 `response_model=` 같은 곳이라면, 파이프 문자(`|`) 대신 `typing`의 `Union`을 사용할 수 있습니다. 예를 들어, 어떤 값이 `str` 또는 `None`이 될 수 있다고 선언할 수 있습니다: ```python from typing import Union def say_hi(name: Union[str, None]): print(f"Hi {name}!") ```Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sat Feb 14 08:57:01 GMT 2026 - 2.4K bytes - Click Count (0) -
docs/zh-hant/docs/advanced/advanced-python-types.md
# 進階 Python 型別 { #advanced-python-types } 以下是一些在使用 Python 型別時可能有用的額外想法。 ## 使用 `Union` 或 `Optional` { #using-union-or-optional } 如果你的程式碼因某些原因無法使用 `|`,例如不是在型別註記中,而是在像 `response_model=` 之類的參數位置,那麼你可以用 `typing` 中的 `Union` 來取代豎線(`|`)。 例如,你可以宣告某個值可以是 `str` 或 `None`: ```python from typing import Union def say_hi(name: Union[str, None]): print(f"Hi {name}!") ``` 在 `typing` 中也有用 `Optional` 宣告某個值可以是 `None` 的速記法。Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sat Feb 14 08:15:26 GMT 2026 - 1.9K bytes - Click Count (0)