Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .python-version

This file was deleted.

97 changes: 0 additions & 97 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,12 @@ name = "vipyrdocs"
version = "0.1.0"
edition = "2021"

[lib]
name = "_core"
# "cdylib" is necessary to produce a shared library for Python to import from.
crate-type = ["cdylib"]
[[bin]]
name = "vipyrdocs"
path = "src/main.rs" # Adjust if your binary source file is elsewhere

[dependencies]
lazy_static = "1.5.0"
# "extension-module" tells pyo3 we want to build an extension module (skips linking against libpython.so)
# "abi3-py39" tells pyo3 (and maturin) to build using the stable ABI with minimum Python version 3.9
pyo3 = { version = "0.22.4", features = ["extension-module", "abi3-py39"] }
regex = "1.11.1"
rustpython-ast = { version = "0.4.0", features = ["visitor"] }
rustpython-parser = "0.4.0"
Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ Build from source with [cargo](https://www.rust-lang.org/tools/install):
cargo install --path .
```

Or use maturin to build a Python-compatible wheel:

```
maturin develop
```

## 🧪 Usage

```
Expand Down
64 changes: 64 additions & 0 deletions examples/multiline_test_docstrings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
"""
Examples of multi-line test docstrings.

This file demonstrates the new feature that allows test docstrings to have
multi-line descriptions for arrange/act/assert or given/when/then patterns
using indentation-based continuation.
"""


def test_arrange_act_assert_pattern():
"""
arrange: This is a very important part of a very important test so
the arrange sentence has to be loooong and span multiple lines
to properly describe the complex setup.
act: Do the test.
assert: It better not fail 😠.
"""
# Test implementation here
pass


def test_given_when_then_pattern():
"""
given: A complex setup scenario that requires multiple lines
to properly explain all the preconditions and
initial state of the system under test.
when: The user performs an action.
then: The system should respond appropriately with
the expected behavior and state changes.
"""
# Test implementation here
pass


def test_multiline_continuation():
"""
arrange: First we need to set up the database with
initial data that includes users and
their associated permissions and
various configuration settings that
are necessary for this particular test scenario.
act: Execute the migration script.
assert: All tables should be updated correctly and
all constraints should be in place.
"""
# Test implementation here
pass


def function_with_multiline_args(param1, param2, param3):
"""Function demonstrating multiline Args section.

Args:
param1: This is a very long parameter description that needs to
span multiple lines because it describes something complex
and important about the parameter usage.
param2: Short description.
param3: Another long description that also
needs multiple lines to explain properly.

Returns:
A result value.
"""
return param1 + param2 + param3
30 changes: 0 additions & 30 deletions pyproject.toml

This file was deleted.

16 changes: 15 additions & 1 deletion src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub const ERROR_CODE_PREFIX: &str = "D";
pub const MORE_INFO_BASE: &str = " (more info: https://example.com/";
pub const MORE_INFO_BASE: &str = ""; //" (more info: https://example.com/";

pub fn docstr_missing_code() -> String {
format!("{}010", ERROR_CODE_PREFIX)
Expand Down Expand Up @@ -315,3 +315,17 @@ pub fn attr_in_docstr_msg(_attribute: &str) -> String {
attr_in_docstr_code().to_lowercase()
)
}

pub fn duplicate_attr_docstr_code() -> String {
format!("{}065", ERROR_CODE_PREFIX)
}

pub fn duplicate_attr_docstr_msg(_attribute: &str) -> String {
format!(
"{} {} attribute documented multiple times {}{}",
duplicate_attr_docstr_code(),
_attribute,
MORE_INFO_BASE,
attr_in_docstr_code().to_lowercase()
)
}
23 changes: 23 additions & 0 deletions src/debug_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#[cfg(test)]
mod test_debug_attr {
use crate::rule_engine::lint_file;

#[test]
fn test_simple_property() {
let code = r#"
class Class1:
"""Docstring 1.

Attrs:
"""
@property
def attr_1():
"""Docstring 2."""
return "value 1"
"#;
let output = lint_file(code, None);
println!("Test output: {:?}", output);
// Let test fail to see output
assert!(false, "Debug test - output: {:?}", output);
}
}
Loading