mirror of https://github.com/mtshiba/pylyzer
fix: `Union` type can take more than 3 options
This commit is contained in:
parent
ace6c345dd
commit
8be2f4c7d4
|
|
@ -252,9 +252,9 @@ checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
|
|||
|
||||
[[package]]
|
||||
name = "els"
|
||||
version = "0.1.25-nightly.2"
|
||||
version = "0.1.25-nightly.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b2718d575740fbdcd8f91262e3f3c100190ee74344c22a58b8bb201b91a5b4aa"
|
||||
checksum = "93c1aa5d03b6f0b4081797248b7149a30ea7016f22d865210947ebe851189a25"
|
||||
dependencies = [
|
||||
"erg_common",
|
||||
"erg_compiler",
|
||||
|
|
@ -274,9 +274,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "erg_common"
|
||||
version = "0.6.13-nightly.2"
|
||||
version = "0.6.13-nightly.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9ffa2366ff45440b95e7854897574238b17e2ceeae419563f6eacb764dd294e"
|
||||
checksum = "a00c25d402e2a7b0a25c6104cce9556d05e063193f4c1f793a26265497a6586e"
|
||||
dependencies = [
|
||||
"backtrace-on-stack-overflow",
|
||||
"hermit-abi",
|
||||
|
|
@ -286,9 +286,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "erg_compiler"
|
||||
version = "0.6.13-nightly.2"
|
||||
version = "0.6.13-nightly.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "920553db0288f2d09ca30f218aeb810874071e898963591b0b3b2fc13ea7b8a6"
|
||||
checksum = "430581161391be0ab5d2045fc66830ba38d29fc435539050f69abfa9dc062e34"
|
||||
dependencies = [
|
||||
"erg_common",
|
||||
"erg_parser",
|
||||
|
|
@ -296,9 +296,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "erg_parser"
|
||||
version = "0.6.13-nightly.2"
|
||||
version = "0.6.13-nightly.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6c591017fbe24f97c1bcc7b8a0ba52c68129c9a039ac169c12e804703f94a4b"
|
||||
checksum = "576308cf389047744b0bbacd6715092e07f049dd06be92299b06d04a8b9499cf"
|
||||
dependencies = [
|
||||
"erg_common",
|
||||
"unicode-xid 0.2.4",
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ edition = "2021"
|
|||
repository = "https://github.com/mtshiba/pylyzer"
|
||||
|
||||
[workspace.dependencies]
|
||||
erg_common = { version = "0.6.13-nightly.2", features = ["py_compat", "els"] }
|
||||
erg_compiler = { version = "0.6.13-nightly.2", features = ["py_compat", "els"] }
|
||||
els = { version = "0.1.25-nightly.2", features = ["py_compat"] }
|
||||
erg_common = { version = "0.6.13-nightly.3", features = ["py_compat", "els"] }
|
||||
erg_compiler = { version = "0.6.13-nightly.3", features = ["py_compat", "els"] }
|
||||
els = { version = "0.1.25-nightly.3", features = ["py_compat"] }
|
||||
rustpython-parser = "0.1.2"
|
||||
# erg_compiler = { git = "https://github.com/erg-lang/erg", branch = "main", features = ["py_compat", "els"] }
|
||||
# erg_common = { git = "https://github.com/erg-lang/erg", branch = "main", features = ["py_compat", "els"] }
|
||||
|
|
|
|||
|
|
@ -525,7 +525,12 @@ impl ASTConverter {
|
|||
};
|
||||
let lhs = self.convert_type_spec(elements.remove(0));
|
||||
let rhs = self.convert_type_spec(elements.remove(0));
|
||||
TypeSpec::or(lhs, rhs)
|
||||
let mut union = TypeSpec::or(lhs, rhs);
|
||||
for elem in elements {
|
||||
let t = self.convert_type_spec(elem);
|
||||
union = TypeSpec::or(union, t);
|
||||
}
|
||||
union
|
||||
}
|
||||
"Optional" => {
|
||||
let loc = args.location;
|
||||
|
|
|
|||
|
|
@ -20,3 +20,7 @@ _ = dic2["c"] # OK
|
|||
t: tuple[int, str] = (1, "a")
|
||||
_ = t[0] == 1 # OK
|
||||
_ = t[1] == 1 # ERR
|
||||
|
||||
def f(s: Str): return None
|
||||
for i in getattr(1, "aaa", ()):
|
||||
f(i)
|
||||
|
|
|
|||
|
|
@ -29,3 +29,10 @@ _: Iterable[int] = ["a"] # ERR
|
|||
|
||||
_: Mapping[str, int] = {"a": 1, "c": 2} # OK
|
||||
_: Mapping[str, int] = {1: "a", 2: "b"} # ERR
|
||||
|
||||
def f(x: Union[int, str, None]):
|
||||
pass
|
||||
# OK
|
||||
f(1)
|
||||
f("a")
|
||||
f(None)
|
||||
|
|
|
|||
Loading…
Reference in New Issue