diff --git a/Cargo.toml b/Cargo.toml index 5d8e912..51dd0cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,3 @@ [workspace] members = ["crates/codebook", "crates/codebook-config", "crates/codebook-lsp", "crates/downloader"] resolver = "2" - -[profile.test] -env = { RUST_LOG = "debug" } diff --git a/Makefile b/Makefile index a40e224..16a2c19 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ MAKEFLAGS += -j4 .PHONY: * -export RUST_LOG=info +export RUST_LOG=debug test: cargo test --lib --bins --tests -- --test-threads=20 diff --git a/README.md b/README.md index 75d3bbb..e3c2b01 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Codebook is being developed, but the Zed extension is now live! Currently only U | Go | ⚠️ | | JavaScript | ✅ | | TypeScript | ⚠️ | -| Python | ⚠️ | +| Python | ✅ | | Rust | ✅ | | TOML | ✅ | diff --git a/crates/codebook/src/queries.rs b/crates/codebook/src/queries.rs index 77ac8b6..a97c2b6 100644 --- a/crates/codebook/src/queries.rs +++ b/crates/codebook/src/queries.rs @@ -113,6 +113,8 @@ pub static LANGUAGE_SETTINGS: &[LanguageSetting] = &[ parameters: (parameters) @identifier) (class_definition name: (identifier) @identifier) + (assignment + (identifier) @identifier) "#, extensions: &["py"], }, diff --git a/crates/codebook/tests/test_python.rs b/crates/codebook/tests/test_python.rs index 4b0e4ed..fc692ec 100644 --- a/crates/codebook/tests/test_python.rs +++ b/crates/codebook/tests/test_python.rs @@ -132,3 +132,70 @@ def constructor(): assert!(misspelled.iter().find(|r| r.word == word).is_none()); } } + +#[test] +fn test_python_global_variables() { + utils::init_logging(); + let processor = utils::get_processor(); + let sample_text = r#" +# Globul variables +globalCountr = 0 +mesage = "Helllo Wolrd!" + "#; + let expected = vec![ + WordLocation::new( + "Globul".to_string(), + vec![TextRange { + start_char: 2, + end_char: 8, + line: 1, + }], + ), + WordLocation::new( + "Countr".to_string(), + vec![TextRange { + start_char: 6, + end_char: 12, + line: 2, + }], + ), + WordLocation::new( + "mesage".to_string(), + vec![TextRange { + start_char: 0, + end_char: 6, + line: 3, + }], + ), + WordLocation::new( + "Helllo".to_string(), + vec![TextRange { + start_char: 10, + end_char: 16, + line: 3, + }], + ), + WordLocation::new( + "Wolrd".to_string(), + vec![TextRange { + start_char: 17, + end_char: 22, + line: 3, + }], + ), + ]; + + let misspelled = processor + .spell_check(sample_text, Some(LanguageType::Python), None) + .to_vec(); + println!("Misspelled words: {misspelled:?}"); + + for e in &expected { + let miss = misspelled + .iter() + .find(|r| r.word == e.word) + .expect(format!("Word '{}' not found in misspelled list", e.word).as_str()); + println!("Expecting: {e:?}"); + assert_eq!(miss.locations, e.locations); + } +}