Skip to content

Pylint hangs when trying to lint a pyo3 enum with named fields #10513

@viktor-refeyn

Description

@viktor-refeyn

Bug description

Compiling the below Rust code gives me a working binary, that I can then import as a module and run without any issues. However when I try to run pylint on the code that calls it pylint simply just hangs while trying to lint the binary.

use pyo3::types::PyModuleMethods;

#[pyo3::pyclass]
#[pyo3(module = "happy_hour.refreshments")]
#[derive(Clone, PartialEq)]
pub enum Cocktails {
    Mojito {
        sugar: u32,
        rum: u32,
        mint: u32,
        lime_wedges: u32,
        soda_water: u32,
        consumers: Vec<u32>,
    },
    MintJulep {
        bourbon: u32,
        mint: u32,
        consumers: Vec<u32>,
    },
}

#[pyo3::pymodule]
fn refreshments(
    py: pyo3::Python<'_>,
    m: &pyo3::Bound<pyo3::prelude::PyModule>,
) -> pyo3::PyResult<()> {
    m.add_class::<Cocktails>()?;

    return Ok(());
}

This essentially boils down to this:

class Cocktails:
    @final
    class Mojito(Cocktails):
        sugar: int
        rum: int
        mint: int
        lime_wedges: int
        soda_water: int
        consumers: list[int]

    @final
    class MintJulep(Cocktails):
        bourbon: int
        mint: int
        consumers: list[int]

Command used

pylint module/xy.py

Pylint output

pylint hangs on run.

When I hook up a debugger I get it recursively calling transforms._visit() and transforms._visit_generic()

Image

Expected behavior

Expecting the linting to finish without any issues

Pylint version

pylint 3.3.8
astroid 3.3.11
Python 3.12.10

OS / Environment

Windows 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    AstroidRelated to astroidBug 🪲Needs astroid updateNeeds an astroid update (probably a release too) before being mergableNeeds reproduction 🔍Need a way to reproduce it locally on a maintainer's machine

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions