Compare commits

..

No commits in common. "main" and "v0.0.81" have entirely different histories.

7 changed files with 44 additions and 120 deletions

View File

@ -6,8 +6,5 @@
"[typescript]": { "[typescript]": {
"editor.formatOnSave": true, "editor.formatOnSave": true,
"editor.defaultFormatter": "biomejs.biome" "editor.defaultFormatter": "biomejs.biome"
}, }
"cSpell.words": [
"indexmap"
]
} }

53
Cargo.lock generated
View File

@ -152,9 +152,9 @@ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
[[package]] [[package]]
name = "els" name = "els"
version = "0.1.65-nightly.5" version = "0.1.65-nightly.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cbf48dcb22f23c344ebcf751ba479ea2d770782826659d5ac0e341f6b971432" checksum = "1dd708f21ce87a184ff5c9010afe61169b021a986fa1f0480ce93f7069308b34"
dependencies = [ dependencies = [
"erg_common", "erg_common",
"erg_compiler", "erg_compiler",
@ -166,17 +166,11 @@ dependencies = [
"windows", "windows",
] ]
[[package]]
name = "equivalent"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]] [[package]]
name = "erg_common" name = "erg_common"
version = "0.6.53-nightly.5" version = "0.6.53-nightly.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e712be33223eb2376056e5864c32290b592058c5ebdfaf27562e5196cb6ae74a" checksum = "fc22c2d3966dfd49dc4e3d142a4c066acfbc2debbf807bd80239640263f82906"
dependencies = [ dependencies = [
"backtrace-on-stack-overflow", "backtrace-on-stack-overflow",
"erg_proc_macros", "erg_proc_macros",
@ -187,9 +181,9 @@ dependencies = [
[[package]] [[package]]
name = "erg_compiler" name = "erg_compiler"
version = "0.6.53-nightly.5" version = "0.6.53-nightly.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84555ce7074c7c068f64393630add858d5b4d9ccd9c304f5c8274ddae291c58c" checksum = "33a71fd95255b255147476dba4b043babe82350d1b32c3bd2b716b5c801ac455"
dependencies = [ dependencies = [
"erg_common", "erg_common",
"erg_parser", "erg_parser",
@ -197,9 +191,9 @@ dependencies = [
[[package]] [[package]]
name = "erg_parser" name = "erg_parser"
version = "0.6.53-nightly.5" version = "0.6.53-nightly.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e28e444531ca109213845ff38f96e1717f26018ed7cc857e5c8fd4ff29bf3800" checksum = "283375be7368b88ab745eeb2530c4a276325d36d41f664935c6521cd2afe4043"
dependencies = [ dependencies = [
"erg_common", "erg_common",
"erg_proc_macros", "erg_proc_macros",
@ -208,9 +202,9 @@ dependencies = [
[[package]] [[package]]
name = "erg_proc_macros" name = "erg_proc_macros"
version = "0.6.53-nightly.5" version = "0.6.53-nightly.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbe0c49c58f7bd9003582c725ce0050bcac6c3754f408e24793c0a29102de9ce" checksum = "222a96d889f1f49149a1d20e634096a82fc575dfe49661d8e713ebcfb152ef71"
dependencies = [ dependencies = [
"quote", "quote",
"syn 1.0.109", "syn 1.0.109",
@ -266,12 +260,6 @@ dependencies = [
"ahash", "ahash",
] ]
[[package]]
name = "hashbrown"
version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
[[package]] [[package]]
name = "heck" name = "heck"
version = "0.5.0" version = "0.5.0"
@ -417,16 +405,6 @@ dependencies = [
"icu_properties", "icu_properties",
] ]
[[package]]
name = "indexmap"
version = "2.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652"
dependencies = [
"equivalent",
"hashbrown 0.15.2",
]
[[package]] [[package]]
name = "is-macro" name = "is-macro"
version = "0.3.7" version = "0.3.7"
@ -524,7 +502,7 @@ version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ea0ed76adf7defc1a92240b5c36d5368cfe9251640dcce5bd2d0b7c1fd87aeb" checksum = "5ea0ed76adf7defc1a92240b5c36d5368cfe9251640dcce5bd2d0b7c1fd87aeb"
dependencies = [ dependencies = [
"hashbrown 0.14.5", "hashbrown",
"itertools", "itertools",
"libm", "libm",
"ryu", "ryu",
@ -739,7 +717,7 @@ dependencies = [
[[package]] [[package]]
name = "py2erg" name = "py2erg"
version = "0.0.82" version = "0.0.81"
dependencies = [ dependencies = [
"erg_common", "erg_common",
"erg_compiler", "erg_compiler",
@ -749,19 +727,18 @@ dependencies = [
[[package]] [[package]]
name = "pylyzer" name = "pylyzer"
version = "0.0.82" version = "0.0.81"
dependencies = [ dependencies = [
"els", "els",
"erg_common", "erg_common",
"erg_compiler", "erg_compiler",
"glob", "glob",
"indexmap",
"pylyzer_core", "pylyzer_core",
] ]
[[package]] [[package]]
name = "pylyzer_core" name = "pylyzer_core"
version = "0.0.82" version = "0.0.81"
dependencies = [ dependencies = [
"erg_common", "erg_common",
"erg_compiler", "erg_compiler",
@ -772,7 +749,7 @@ dependencies = [
[[package]] [[package]]
name = "pylyzer_wasm" name = "pylyzer_wasm"
version = "0.0.82" version = "0.0.81"
dependencies = [ dependencies = [
"erg_common", "erg_common",
"erg_compiler", "erg_compiler",

View File

@ -17,16 +17,16 @@ members = [
] ]
[workspace.package] [workspace.package]
version = "0.0.82" version = "0.0.81"
authors = ["Shunsuke Shibayama <sbym1346@gmail.com>"] authors = ["Shunsuke Shibayama <sbym1346@gmail.com>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2021" edition = "2021"
repository = "https://github.com/mtshiba/pylyzer" repository = "https://github.com/mtshiba/pylyzer"
[workspace.dependencies] [workspace.dependencies]
erg_common = { version = "0.6.53-nightly.5", features = ["py_compat", "els"] } erg_common = { version = "0.6.53-nightly.2", features = ["py_compat", "els"] }
erg_compiler = { version = "0.6.53-nightly.5", features = ["py_compat", "els"] } erg_compiler = { version = "0.6.53-nightly.2", features = ["py_compat", "els"] }
els = { version = "0.1.65-nightly.5", features = ["py_compat"] } els = { version = "0.1.65-nightly.2", features = ["py_compat"] }
# rustpython-parser = { version = "0.3.0", features = ["all-nodes-with-ranges", "location"] } # rustpython-parser = { version = "0.3.0", features = ["all-nodes-with-ranges", "location"] }
# rustpython-ast = { version = "0.3.0", features = ["all-nodes-with-ranges", "location"] } # rustpython-ast = { version = "0.3.0", features = ["all-nodes-with-ranges", "location"] }
rustpython-parser = { git = "https://github.com/RustPython/Parser", version = "0.4.0", features = ["all-nodes-with-ranges", "location"] } rustpython-parser = { git = "https://github.com/RustPython/Parser", version = "0.4.0", features = ["all-nodes-with-ranges", "location"] }
@ -50,11 +50,10 @@ simplified_chinese = ["erg_common/simplified_chinese", "els/simplified_chinese"]
traditional_chinese = ["erg_common/traditional_chinese", "els/traditional_chinese"] traditional_chinese = ["erg_common/traditional_chinese", "els/traditional_chinese"]
[dependencies] [dependencies]
pylyzer_core = { version = "0.0.82", path = "./crates/pylyzer_core" } pylyzer_core = { version = "0.0.81", path = "./crates/pylyzer_core" }
erg_common = { workspace = true } erg_common = { workspace = true }
els = { workspace = true } els = { workspace = true }
glob = "0.3.2" glob = "0.3.2"
indexmap = "2.7.1"
[dev-dependencies] [dev-dependencies]
erg_compiler = { workspace = true } erg_compiler = { workspace = true }

View File

@ -1,9 +1,5 @@
# pylyzer ⚡ # pylyzer ⚡
> [!IMPORTANT]
> pylyzer is now under the maintenance phase, which means that only bug fixes will be made and no new features will be added.
The author is currently cooperating with the development of [astral-sh/ty](https://github.com/astral-sh/ty). Please try that instead!
![pylyzer_logo_with_letters](https://raw.githubusercontent.com/mtshiba/pylyzer/main/images/pylyzer-logo-with-letters.png) ![pylyzer_logo_with_letters](https://raw.githubusercontent.com/mtshiba/pylyzer/main/images/pylyzer-logo-with-letters.png)
<a href="https://marketplace.visualstudio.com/items?itemName=pylyzer.pylyzer" target="_blank" rel="noreferrer noopener nofollow"><img src="https://img.shields.io/visual-studio-marketplace/v/pylyzer.pylyzer?style=flat&amp;label=VS%20Marketplace&amp;logo=visual-studio-code" alt="vsm-version"></a> <a href="https://marketplace.visualstudio.com/items?itemName=pylyzer.pylyzer" target="_blank" rel="noreferrer noopener nofollow"><img src="https://img.shields.io/visual-studio-marketplace/v/pylyzer.pylyzer?style=flat&amp;label=VS%20Marketplace&amp;logo=visual-studio-code" alt="vsm-version"></a>
@ -45,7 +41,7 @@ Make sure that `cargo`/`rustc` is up-to-date, as pylyzer may be written with the
pylyzer file.py pylyzer file.py
``` ```
### Check multiple files ## Check multiple files
```sh ```sh
# glob patterns are supported # glob patterns are supported

View File

@ -20,7 +20,7 @@ erg_common = { workspace = true }
erg_compiler = { workspace = true } erg_compiler = { workspace = true }
rustpython-parser = { workspace = true } rustpython-parser = { workspace = true }
rustpython-ast = { workspace = true } rustpython-ast = { workspace = true }
py2erg = { version = "0.0.82", path = "../py2erg" } py2erg = { version = "0.0.81", path = "../py2erg" }
[lib] [lib]
path = "lib.rs" path = "lib.rs"

View File

@ -6,7 +6,6 @@ use erg_common::config::{ErgConfig, ErgMode};
use erg_common::io::Input; use erg_common::io::Input;
use erg_common::pathutil::project_entry_file_of; use erg_common::pathutil::project_entry_file_of;
use erg_common::switch_lang; use erg_common::switch_lang;
use indexmap::IndexSet;
use crate::copy::clear_cache; use crate::copy::clear_cache;
@ -50,7 +49,7 @@ OPTIONS
--clear-cache --clear-cache
--code/-c cmd --code/-c cmd
--dump-decl --dump-decl
--disable feat ", --disable ",
"simplified_chinese" => "simplified_chinese" =>
"\ "\
@ -68,7 +67,7 @@ OPTIONS
--clear-cache --clear-cache
--code/-c cmd --code/-c cmd
--dump-decl --dump-decl
--disable feat ", --disable ",
"traditional_chinese" => "traditional_chinese" =>
"\ "\
@ -86,7 +85,7 @@ OPTIONS
--clear-cache --clear-cache
--code/-c cmd --code/-c cmd
--dump-decl --dump-decl
--disable feat ", --disable ",
"english" => "english" =>
"\ "\
@ -104,7 +103,7 @@ OPTIONS
--clear-cache clear cache --clear-cache clear cache
--code/-c cmd program passed in as string --code/-c cmd program passed in as string
--dump-decl output type declaration file --dump-decl output type declaration file
--disable feat disable specified features", --disable disable specified features",
) )
} }
@ -214,53 +213,21 @@ For more information try `pylyzer --help`"
cfg cfg
} }
pub(crate) fn files_to_be_checked() -> IndexSet<Result<PathBuf, String>> { pub(crate) fn files_to_be_checked() -> Vec<PathBuf> {
let mut file_or_patterns = vec![]; let file_or_patterns = env::args()
let mut args = env::args().skip(1); .skip(1)
while let Some(arg) = &args.next() { .rev()
match arg.as_str() { .take_while(|arg| !arg.starts_with("-"));
"--" => { let mut files = vec![];
// Discard runtime args
break;
}
"--code" | "-c" | "--disable" | "--verbose" => {
// Skip options
let _ = &args.next();
continue;
}
file_or_pattern if file_or_pattern.starts_with("-") => {
// Skip flags
continue;
}
file_or_pattern => file_or_patterns.push(file_or_pattern.to_owned()),
}
}
let mut files = IndexSet::new();
for file_or_pattern in file_or_patterns { for file_or_pattern in file_or_patterns {
if PathBuf::from(&file_or_pattern).is_file() { if PathBuf::from(&file_or_pattern).is_file() {
files.insert(Ok(PathBuf::from(&file_or_pattern))); files.push(PathBuf::from(&file_or_pattern));
} else { } else {
let entries = glob::glob(&file_or_pattern); for entry in glob::glob(&file_or_pattern).expect("Failed to read glob pattern") {
match entries { match entry {
Err(_) => { Err(e) => eprintln!("err: {e}"),
files.insert(Err(file_or_pattern)); Ok(path) if path.is_file() => files.push(path),
continue; _ => {}
}
Ok(entries) => {
let mut entries = entries.into_iter().peekable();
if entries.peek().is_none() {
files.insert(Err(file_or_pattern));
}
for entry in entries {
match entry {
Err(e) => eprintln!("err: {e}"),
Ok(path) if path.is_file() => {
files.insert(Ok(path));
}
_ => {}
}
}
} }
} }
} }

View File

@ -4,8 +4,6 @@ mod copy;
use els::Server; use els::Server;
use erg_common::config::ErgMode; use erg_common::config::ErgMode;
use erg_common::spawn::exec_new_thread; use erg_common::spawn::exec_new_thread;
use erg_common::style::colors::RED;
use erg_common::style::RESET;
use pylyzer_core::{PythonAnalyzer, SimplePythonParser}; use pylyzer_core::{PythonAnalyzer, SimplePythonParser};
use crate::config::files_to_be_checked; use crate::config::files_to_be_checked;
@ -25,21 +23,11 @@ fn run() {
code = analyzer.run(); code = analyzer.run();
} else { } else {
for path in files { for path in files {
match path { let cfg = cfg.inherit(path);
Err(invalid_file_or_pattern) => { let mut analyzer = PythonAnalyzer::new(cfg);
if code == 0 { let c = analyzer.run();
code = 1; if c != 0 {
} code = 1;
println!("{RED}Invalid file or pattern{RESET}: {invalid_file_or_pattern}");
}
Ok(path) => {
let cfg = cfg.inherit(path);
let mut analyzer = PythonAnalyzer::new(cfg);
let c = analyzer.run();
if c != 0 {
code = 1;
}
}
} }
} }
} }