From 82b029c3bf66ce11cde0bfafda6359964feb10f6 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 11 Apr 2022 14:34:29 +0200 Subject: [PATCH] Use Optional[Type] instead of Union[Type, None] --- compiler/api/compiler.py | 2 +- compiler/api/template/combinator.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/api/compiler.py b/compiler/api/compiler.py index cc8be2d7..adc6cfff 100644 --- a/compiler/api/compiler.py +++ b/compiler/api/compiler.py @@ -115,7 +115,7 @@ def get_type_hint(type: str) -> str: type = f"List[{get_type_hint(sub_type)}]" if is_core: - return f"Union[None, {type}] = None" if is_flag else type + return f"Optional[{type}] = None" if is_flag else type else: ns, name = type.split(".") if "." in type else ("", type) type = f'"raw.base.' + ".".join([ns, name]).strip(".") + '"' diff --git a/compiler/api/template/combinator.txt b/compiler/api/template/combinator.txt index e0275dd1..7c02a1a8 100644 --- a/compiler/api/template/combinator.txt +++ b/compiler/api/template/combinator.txt @@ -5,7 +5,7 @@ from io import BytesIO from pyrogram.raw.core.primitives import Int, Long, Int128, Int256, Bool, Bytes, String, Double, Vector from pyrogram.raw.core import TLObject from pyrogram import raw -from typing import List, Union, Any +from typing import List, Optional, Any {warning}