-
Notifications
You must be signed in to change notification settings - Fork 784
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #826 from kngwyu/pyclass-err-improve
More ergonomic error messages for invalid #[pyclass] args
- Loading branch information
Showing
4 changed files
with
79 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use pyo3::prelude::*; | ||
|
||
#[pyclass(extend=pyo3::types::PyDict)] | ||
struct TypoIntheKey {} | ||
|
||
#[pyclass(extends = "PyDict")] | ||
struct InvalidExtends {} | ||
|
||
#[pyclass(name = m::MyClass)] | ||
struct InvalidName {} | ||
|
||
#[pyclass(module = my_module)] | ||
struct InvalidModule {} | ||
|
||
#[pyclass(weakrev)] | ||
struct InvalidArg {} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
error: Expected one of freelist/name/extends/module | ||
--> $DIR/invalid_pyclass_args.rs:3:11 | ||
| | ||
3 | #[pyclass(extend=pyo3::types::PyDict)] | ||
| ^^^^^^ | ||
|
||
error: Expected type path (e.g., my_mod::BaseClass) | ||
--> $DIR/invalid_pyclass_args.rs:6:21 | ||
| | ||
6 | #[pyclass(extends = "PyDict")] | ||
| ^^^^^^^^ | ||
|
||
error: Expected type name (e.g., Name) | ||
--> $DIR/invalid_pyclass_args.rs:9:18 | ||
| | ||
9 | #[pyclass(name = m::MyClass)] | ||
| ^^^^^^^^^^ | ||
|
||
error: Expected string literal (e.g., "my_mod") | ||
--> $DIR/invalid_pyclass_args.rs:12:20 | ||
| | ||
12 | #[pyclass(module = my_module)] | ||
| ^^^^^^^^^ | ||
|
||
error: Expected one of gc/weakref/subclass/dict | ||
--> $DIR/invalid_pyclass_args.rs:15:11 | ||
| | ||
15 | #[pyclass(weakrev)] | ||
| ^^^^^^^ |