mirror of https://github.com/mtshiba/pylyzer
Compare commits
No commits in common. "main" and "v0.0.81" have entirely different histories.
|
|
@ -6,8 +6,5 @@
|
|||
"[typescript]": {
|
||||
"editor.formatOnSave": true,
|
||||
"editor.defaultFormatter": "biomejs.biome"
|
||||
},
|
||||
"cSpell.words": [
|
||||
"indexmap"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -152,9 +152,9 @@ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
|
|||
|
||||
[[package]]
|
||||
name = "els"
|
||||
version = "0.1.65-nightly.5"
|
||||
version = "0.1.65-nightly.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5cbf48dcb22f23c344ebcf751ba479ea2d770782826659d5ac0e341f6b971432"
|
||||
checksum = "1dd708f21ce87a184ff5c9010afe61169b021a986fa1f0480ce93f7069308b34"
|
||||
dependencies = [
|
||||
"erg_common",
|
||||
"erg_compiler",
|
||||
|
|
@ -166,17 +166,11 @@ dependencies = [
|
|||
"windows",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
||||
|
||||
[[package]]
|
||||
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"
|
||||
checksum = "e712be33223eb2376056e5864c32290b592058c5ebdfaf27562e5196cb6ae74a"
|
||||
checksum = "fc22c2d3966dfd49dc4e3d142a4c066acfbc2debbf807bd80239640263f82906"
|
||||
dependencies = [
|
||||
"backtrace-on-stack-overflow",
|
||||
"erg_proc_macros",
|
||||
|
|
@ -187,9 +181,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
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"
|
||||
checksum = "84555ce7074c7c068f64393630add858d5b4d9ccd9c304f5c8274ddae291c58c"
|
||||
checksum = "33a71fd95255b255147476dba4b043babe82350d1b32c3bd2b716b5c801ac455"
|
||||
dependencies = [
|
||||
"erg_common",
|
||||
"erg_parser",
|
||||
|
|
@ -197,9 +191,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
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"
|
||||
checksum = "e28e444531ca109213845ff38f96e1717f26018ed7cc857e5c8fd4ff29bf3800"
|
||||
checksum = "283375be7368b88ab745eeb2530c4a276325d36d41f664935c6521cd2afe4043"
|
||||
dependencies = [
|
||||
"erg_common",
|
||||
"erg_proc_macros",
|
||||
|
|
@ -208,9 +202,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
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"
|
||||
checksum = "dbe0c49c58f7bd9003582c725ce0050bcac6c3754f408e24793c0a29102de9ce"
|
||||
checksum = "222a96d889f1f49149a1d20e634096a82fc575dfe49661d8e713ebcfb152ef71"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
|
|
@ -266,12 +260,6 @@ dependencies = [
|
|||
"ahash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.15.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
|
|
@ -417,16 +405,6 @@ dependencies = [
|
|||
"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]]
|
||||
name = "is-macro"
|
||||
version = "0.3.7"
|
||||
|
|
@ -524,7 +502,7 @@ version = "0.4.22"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ea0ed76adf7defc1a92240b5c36d5368cfe9251640dcce5bd2d0b7c1fd87aeb"
|
||||
dependencies = [
|
||||
"hashbrown 0.14.5",
|
||||
"hashbrown",
|
||||
"itertools",
|
||||
"libm",
|
||||
"ryu",
|
||||
|
|
@ -739,7 +717,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "py2erg"
|
||||
version = "0.0.82"
|
||||
version = "0.0.81"
|
||||
dependencies = [
|
||||
"erg_common",
|
||||
"erg_compiler",
|
||||
|
|
@ -749,19 +727,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "pylyzer"
|
||||
version = "0.0.82"
|
||||
version = "0.0.81"
|
||||
dependencies = [
|
||||
"els",
|
||||
"erg_common",
|
||||
"erg_compiler",
|
||||
"glob",
|
||||
"indexmap",
|
||||
"pylyzer_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pylyzer_core"
|
||||
version = "0.0.82"
|
||||
version = "0.0.81"
|
||||
dependencies = [
|
||||
"erg_common",
|
||||
"erg_compiler",
|
||||
|
|
@ -772,7 +749,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "pylyzer_wasm"
|
||||
version = "0.0.82"
|
||||
version = "0.0.81"
|
||||
dependencies = [
|
||||
"erg_common",
|
||||
"erg_compiler",
|
||||
|
|
|
|||
11
Cargo.toml
11
Cargo.toml
|
|
@ -17,16 +17,16 @@ members = [
|
|||
]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.0.82"
|
||||
version = "0.0.81"
|
||||
authors = ["Shunsuke Shibayama <sbym1346@gmail.com>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
edition = "2021"
|
||||
repository = "https://github.com/mtshiba/pylyzer"
|
||||
|
||||
[workspace.dependencies]
|
||||
erg_common = { version = "0.6.53-nightly.5", features = ["py_compat", "els"] }
|
||||
erg_compiler = { version = "0.6.53-nightly.5", features = ["py_compat", "els"] }
|
||||
els = { version = "0.1.65-nightly.5", features = ["py_compat"] }
|
||||
erg_common = { version = "0.6.53-nightly.2", features = ["py_compat", "els"] }
|
||||
erg_compiler = { version = "0.6.53-nightly.2", features = ["py_compat", "els"] }
|
||||
els = { version = "0.1.65-nightly.2", features = ["py_compat"] }
|
||||
# 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-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"]
|
||||
|
||||
[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 }
|
||||
els = { workspace = true }
|
||||
glob = "0.3.2"
|
||||
indexmap = "2.7.1"
|
||||
|
||||
[dev-dependencies]
|
||||
erg_compiler = { workspace = true }
|
||||
|
|
|
|||
|
|
@ -1,9 +1,5 @@
|
|||
# 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!
|
||||
|
||||

|
||||
|
||||
<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&label=VS%20Marketplace&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
|
||||
```
|
||||
|
||||
### Check multiple files
|
||||
## Check multiple files
|
||||
|
||||
```sh
|
||||
# glob patterns are supported
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ erg_common = { workspace = true }
|
|||
erg_compiler = { workspace = true }
|
||||
rustpython-parser = { workspace = true }
|
||||
rustpython-ast = { workspace = true }
|
||||
py2erg = { version = "0.0.82", path = "../py2erg" }
|
||||
py2erg = { version = "0.0.81", path = "../py2erg" }
|
||||
|
||||
[lib]
|
||||
path = "lib.rs"
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ use erg_common::config::{ErgConfig, ErgMode};
|
|||
use erg_common::io::Input;
|
||||
use erg_common::pathutil::project_entry_file_of;
|
||||
use erg_common::switch_lang;
|
||||
use indexmap::IndexSet;
|
||||
|
||||
use crate::copy::clear_cache;
|
||||
|
||||
|
|
@ -50,7 +49,7 @@ OPTIONS
|
|||
--clear-cache キャッシュをクリア
|
||||
--code/-c cmd 文字列をプログラムに渡す
|
||||
--dump-decl 型宣言ファイルを出力
|
||||
--disable feat 指定した機能を無効化",
|
||||
--disable 指定した機能を無効化",
|
||||
|
||||
"simplified_chinese" =>
|
||||
"\
|
||||
|
|
@ -68,7 +67,7 @@ OPTIONS
|
|||
--clear-cache 清除缓存
|
||||
--code/-c cmd 作为字符串传入程序
|
||||
--dump-decl 输出类型声明文件
|
||||
--disable feat 禁用指定功能",
|
||||
--disable 禁用指定功能",
|
||||
|
||||
"traditional_chinese" =>
|
||||
"\
|
||||
|
|
@ -86,7 +85,7 @@ OPTIONS
|
|||
--clear-cache 清除快取
|
||||
--code/-c cmd 作為字串傳入程式
|
||||
--dump-decl 輸出類型宣告檔案
|
||||
--disable feat 禁用指定功能",
|
||||
--disable 禁用指定功能",
|
||||
|
||||
"english" =>
|
||||
"\
|
||||
|
|
@ -104,7 +103,7 @@ OPTIONS
|
|||
--clear-cache clear cache
|
||||
--code/-c cmd program passed in as string
|
||||
--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
|
||||
}
|
||||
|
||||
pub(crate) fn files_to_be_checked() -> IndexSet<Result<PathBuf, String>> {
|
||||
let mut file_or_patterns = vec![];
|
||||
let mut args = env::args().skip(1);
|
||||
while let Some(arg) = &args.next() {
|
||||
match arg.as_str() {
|
||||
"--" => {
|
||||
// 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();
|
||||
pub(crate) fn files_to_be_checked() -> Vec<PathBuf> {
|
||||
let file_or_patterns = env::args()
|
||||
.skip(1)
|
||||
.rev()
|
||||
.take_while(|arg| !arg.starts_with("-"));
|
||||
let mut files = vec![];
|
||||
for file_or_pattern in file_or_patterns {
|
||||
if PathBuf::from(&file_or_pattern).is_file() {
|
||||
files.insert(Ok(PathBuf::from(&file_or_pattern)));
|
||||
files.push(PathBuf::from(&file_or_pattern));
|
||||
} else {
|
||||
let entries = glob::glob(&file_or_pattern);
|
||||
match entries {
|
||||
Err(_) => {
|
||||
files.insert(Err(file_or_pattern));
|
||||
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));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
for entry in glob::glob(&file_or_pattern).expect("Failed to read glob pattern") {
|
||||
match entry {
|
||||
Err(e) => eprintln!("err: {e}"),
|
||||
Ok(path) if path.is_file() => files.push(path),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
22
src/main.rs
22
src/main.rs
|
|
@ -4,8 +4,6 @@ mod copy;
|
|||
use els::Server;
|
||||
use erg_common::config::ErgMode;
|
||||
use erg_common::spawn::exec_new_thread;
|
||||
use erg_common::style::colors::RED;
|
||||
use erg_common::style::RESET;
|
||||
use pylyzer_core::{PythonAnalyzer, SimplePythonParser};
|
||||
|
||||
use crate::config::files_to_be_checked;
|
||||
|
|
@ -25,21 +23,11 @@ fn run() {
|
|||
code = analyzer.run();
|
||||
} else {
|
||||
for path in files {
|
||||
match path {
|
||||
Err(invalid_file_or_pattern) => {
|
||||
if code == 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;
|
||||
}
|
||||
}
|
||||
let cfg = cfg.inherit(path);
|
||||
let mut analyzer = PythonAnalyzer::new(cfg);
|
||||
let c = analyzer.run();
|
||||
if c != 0 {
|
||||
code = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue