Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Package detection doesn't work for PEP518 packages (no setup.py) #136

@Guitaricet

Description

@Guitaricet

Describe the bug

Thank you for working on pylyzer. It's great to have a faster alternative to pytype, which is unbearably slow in large codebases.

We are exploring switching from pytype to pylyzer , but right now pylyzder doesn't support PEP518-configured python pakcages.

More specifically, running

> pylyzer

inside a package set up with pyprojec.toml and without setup.py doesn't analyze the whole package, only a single __init__.py file. This is important, because PEP518 is the way uv sets up packages by default and uv is becoming very popular.

Reproducible Code

mkdir pylyzer_bug
cd pylyzer_bug
uv init --package --build-backend setuptools
cat > src/pylyzer_bug/main.py << 'EOF'
def add(x: int, y: str) -> float:
    return x + y
EOF
source .venv/bin/activate
pylyzer

Environment

OS: Ubuntu 22.04

Expected behavior

Calling pylyzer in package root analyzes all python package inside the package.

Error log

(pylyzer-bug) ~/D/pylyzer_bug ❯❯❯ pylyzer                                                                                                                                                                                                                            main ◼
Start checking: __init__.py
All checks OK: __init__.py

but it should error out like this:

(pylyzer-bug) ~/D/pylyzer_bug ❯❯❯ pylyzer src/pylyzer_bug/main.py                                                                                                                                                                                                    main ◼
Start checking: main.py
Found 1 errors: main.py
Error[#2604]: File src/pylyzer_bug/main.py, line 3, <module>.add

3 |     return x + y
  :                -
  :                |- expected: Int
  :                `- but found: Str

TypeError: the type of `+`::rhs (the 2nd argument) is mismatched

Screenshots

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions