pola-rs/polars · error
didn't recognize attribute
Error message
didn't recognize attribute
What it means
The #[polars] derive macro's attribute parser (pyo3-polars-derive/src/attr.rs:54) panics with "didn't recognize attribute" when it encounters a #[polars(...)] attribute argument it cannot match against the known set (e.g. output_type, output_type_func, output_type_func_with_kwargs, dtype aliases). This is a compile-time proc-macro panic, so the error appears as a rustc build failure, not a runtime exception.
Solutions
- Check the attribute name against the supported list in pyo3-polars-derive (output_type, output_dtype, output_type_func, output_type_func_with_kwargs, etc.) and fix the spelling.
- Pin your pyo3-polars version to match documentation/examples you are following, since the accepted attribute set changes between versions.
- Remove the unknown attribute and specify the output type via a supported attribute or Rust return type inference.
Example fix
// before
#[polars(output_type_function = "my_fn")]n my_expr(x: &Series) -> PolarsResult<Column> { ... }
// after
#[polars(output_type_func = "my_fn")]
fn my_expr(x: &Series) -> PolarsResult<Column> { ... } Defensive patterns
Strategy: validation
Prevention
- Only use attribute names from the pyo3-polars-derive docs for your pinned version.
- Copy attribute usage from the crate's examples/tests rather than other ecosystems.
- Let cargo fail fast in CI — this panic is a compile-time error.
When it happens
Trigger: Writing #[polars(some_unknown_option = "...")] on a function used with #[derive(PolarsExpression)] / macro exports; misspelling an attribute name or passing an unsupported key-value pair.
Common situations: Upgrading pyo3-polars and using attribute names from a different version; copy-pasting attributes from other derive ecosystems (e.g. pyo3); typos like output_type_function.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- didn't understand polars_expr attribute
- data type must be FixedSizeList
- didn't expect argument
- offset + length overflowed
- validity must be equal to the array's length
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/7f7e15531a8e3176.
Report an issue: GitHub.
Appendix: source
Thrown at pyo3-polars/pyo3-polars-derive/src/attr.rs:54
impl Parse for ExprsFunctionOptions {
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
let mut options = ExprsFunctionOptions::default();
while !input.is_empty() {
let lookahead = input.lookahead1();
if lookahead.peek(keywords::output_type) {
let attr = input.parse::<OutputAttribute>()?;
options.output_dtype = Some(attr.value)
} else if lookahead.peek(keywords::output_type_func) {
let attr = input.parse::<OutputFuncAttribute>()?;
options.output_type_fn = Some(attr.value)
} else if lookahead.peek(keywords::output_type_func_with_kwargs) {
let attr = input.parse::<OutputFuncAttributeWithKwargs>()?;
options.output_type_fn_kwargs = Some(attr.value)
} else {
panic!("didn't recognize attribute")
}
}
Ok(options)
}
}
View on GitHub (pinned to fe841f959e)