Git Product home page Git Product logo

pylyzer's People

Contributors

falkwoldmann avatar mtshiba avatar youknowone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pylyzer's Issues

Mason: How do I specify python environment to use in pylyzer?

The issue

#54 might have mentioned that, however they have a different issue. My question is more general.

I have two python environments - virtual env and system environment, which seems to be enforced by default. Why enforced?

When entering nvim, having executed source ./venv/bin/activate, pylyzer can't find installed modules. Example below:

streamlit module is installed, however pylyzer can't see it

Specs

NVIM: v0.9.2
pylyzer: v0.0.45
python env:

:!pip --version
pip 23.0.1 from /home/quakuei/Desktop/iamjaf/spbstu/postgre-tasks-spbstu/car_service/car_service_fr
ontend/venv/lib/python3.8/site-packages/pip (python 3.8)
:!which python                                                                           
/home/quakuei/Desktop/iamjaf/spbstu/postgre-tasks-spbstu/car_service/car_service_frontend/venv/bin/
python

What I've searched

Couldn't find information on that matter in documentation, unfortunately.

This is what I looked through

Saw pyright stackoverflow discussion on similar topic, however solution seems to be related to pyright, and also they used an older version of nvim

Saw venv-selector.nvim on github, however no out-of-box support for pylyzer mentioned.

What can I do to specify the python environment to use for pylyzer?
Thanks.

Compilation errors

I tried cargo install pylyzer but I got compilation errors:

error[E0308]: arguments to this function are incorrect
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/py2erg-0.0.3/convert.rs:126:5
    |
126 |     erg_common::error::Location::range(loc.row(), loc.column(), loc.row(), loc.column() + cont_len)
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---------  ------------  ---------  ----------------------- expected `u32`, found `usize`
    |                                        |          |             |
    |                                        |          |             expected `u32`, found `usize`
    |                                        |          expected `u32`, found `usize`
    |                                        expected `u32`, found `usize`
    |
note: associated function defined here
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_common-0.6.3/error.rs:273:18
    |
273 |     pub const fn range(ln_begin: u32, col_begin: u32, ln_end: u32, col_end: u32) -> Self {
    |                  ^^^^^
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
126 |     erg_common::error::Location::range(loc.row().try_into().unwrap(), loc.column(), loc.row(), loc.column() + cont_len)
    |                                                 ++++++++++++++++++++
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
126 |     erg_common::error::Location::range(loc.row(), loc.column().try_into().unwrap(), loc.row(), loc.column() + cont_len)
    |                                                               ++++++++++++++++++++
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
126 |     erg_common::error::Location::range(loc.row(), loc.column(), loc.row().try_into().unwrap(), loc.column() + cont_len)
    |                                                                          ++++++++++++++++++++
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
126 |     erg_common::error::Location::range(loc.row(), loc.column(), loc.row(), (loc.column() + cont_len).try_into().unwrap())
    |                                                                            +                       +++++++++++++++++++++

error[E0308]: arguments to this function are incorrect
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/py2erg-0.0.3/convert.rs:268:21
    |
268 |         let token = Token::new(TokenKind::Symbol, cont, loc.row(), loc.column() - 1);
    |                     ^^^^^^^^^^                          ---------  ---------------- expected `u32`, found `usize`
    |                                                         |
    |                                                         expected `u32`, found `usize`
    |
note: associated function defined here
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_parser-0.6.3/token.rs:403:12
    |
403 |     pub fn new<S: Into<Str>>(kind: TokenKind, cont: S, lineno: u32, col_begin: u32) -> Self {
    |            ^^^
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
268 |         let token = Token::new(TokenKind::Symbol, cont, loc.row().try_into().unwrap(), loc.column() - 1);
    |                                                                  ++++++++++++++++++++
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
268 |         let token = Token::new(TokenKind::Symbol, cont, loc.row(), (loc.column() - 1).try_into().unwrap());
    |                                                                    +                +++++++++++++++++++++

error[E0308]: arguments to this function are incorrect
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/py2erg-0.0.3/convert.rs:270:19
    |
270 |         let dot = Token::new(TokenKind::Dot, ".", loc.row(), loc.column() - 1);
    |                   ^^^^^^^^^^                      ---------  ---------------- expected `u32`, found `usize`
    |                                                   |
    |                                                   expected `u32`, found `usize`
    |
note: associated function defined here
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_parser-0.6.3/token.rs:403:12
    |
403 |     pub fn new<S: Into<Str>>(kind: TokenKind, cont: S, lineno: u32, col_begin: u32) -> Self {
    |            ^^^
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
270 |         let dot = Token::new(TokenKind::Dot, ".", loc.row().try_into().unwrap(), loc.column() - 1);
    |                                                            ++++++++++++++++++++
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
270 |         let dot = Token::new(TokenKind::Dot, ".", loc.row(), (loc.column() - 1).try_into().unwrap());
    |                                                              +                +++++++++++++++++++++

error[E0308]: arguments to this function are incorrect
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/py2erg-0.0.3/convert.rs:276:21
    |
276 |         let token = Token::new(TokenKind::Symbol, name, loc.row(), loc.column() - 1);
    |                     ^^^^^^^^^^                          ---------  ---------------- expected `u32`, found `usize`
    |                                                         |
    |                                                         expected `u32`, found `usize`
    |
note: associated function defined here
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_parser-0.6.3/token.rs:403:12
    |
403 |     pub fn new<S: Into<Str>>(kind: TokenKind, cont: S, lineno: u32, col_begin: u32) -> Self {
    |            ^^^
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
276 |         let token = Token::new(TokenKind::Symbol, name, loc.row().try_into().unwrap(), loc.column() - 1);
    |                                                                  ++++++++++++++++++++
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
276 |         let token = Token::new(TokenKind::Symbol, name, loc.row(), (loc.column() - 1).try_into().unwrap());
    |                                                                    +                +++++++++++++++++++++

error[E0308]: arguments to this function are incorrect
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/py2erg-0.0.3/convert.rs:278:19
    |
278 |         let dot = Token::new(TokenKind::Dot, ".", loc.row(), loc.column() - 1);
    |                   ^^^^^^^^^^                      ---------  ---------------- expected `u32`, found `usize`
    |                                                   |
    |                                                   expected `u32`, found `usize`
    |
note: associated function defined here
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_parser-0.6.3/token.rs:403:12
    |
403 |     pub fn new<S: Into<Str>>(kind: TokenKind, cont: S, lineno: u32, col_begin: u32) -> Self {
    |            ^^^
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
278 |         let dot = Token::new(TokenKind::Dot, ".", loc.row().try_into().unwrap(), loc.column() - 1);
    |                                                            ++++++++++++++++++++
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
278 |         let dot = Token::new(TokenKind::Dot, ".", loc.row(), (loc.column() - 1).try_into().unwrap());
    |                                                              +                +++++++++++++++++++++

error[E0308]: arguments to this function are incorrect
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/py2erg-0.0.3/convert.rs:283:21
    |
283 |         let token = Token::new(TokenKind::Symbol, arg, loc.row(), loc.column() - 1);
    |                     ^^^^^^^^^^                         ---------  ---------------- expected `u32`, found `usize`
    |                                                        |
    |                                                        expected `u32`, found `usize`
    |
note: associated function defined here
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_parser-0.6.3/token.rs:403:12
    |
403 |     pub fn new<S: Into<Str>>(kind: TokenKind, cont: S, lineno: u32, col_begin: u32) -> Self {
    |            ^^^
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
283 |         let token = Token::new(TokenKind::Symbol, arg, loc.row().try_into().unwrap(), loc.column() - 1);
    |                                                                 ++++++++++++++++++++
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
283 |         let token = Token::new(TokenKind::Symbol, arg, loc.row(), (loc.column() - 1).try_into().unwrap());
    |                                                                   +                +++++++++++++++++++++

error[E0308]: mismatched types
    --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/py2erg-0.0.3/convert.rs:337:74
     |
337  |                 let tmp_name = VarName::from_str_and_line((&tmp).into(), expr.location.row());
     |                                --------------------------                ^^^^^^^^^^^^^^^^^^^ expected `u32`, found `usize`
     |                                |
     |                                arguments to this function are incorrect
     |
note: associated function defined here
    --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_parser-0.6.3/ast.rs:2320:12
     |
2320 |     pub fn from_str_and_line(symbol: Str, line: u32) -> Self {
     |            ^^^^^^^^^^^^^^^^^
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
     |
337  |                 let tmp_name = VarName::from_str_and_line((&tmp).into(), expr.location.row().try_into().unwrap());
     |                                                                                             ++++++++++++++++++++

error[E0308]: arguments to this function are incorrect
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/py2erg-0.0.3/convert.rs:344:46
    |
344 |                     let index = Literal::new(Token::new(
    |                                              ^^^^^^^^^^
...
347 |                         elem.location.row(),
    |                         ------------------- expected `u32`, found `usize`
348 |                         elem.location.column() - 1,
    |                         -------------------------- expected `u32`, found `usize`
    |
note: associated function defined here
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_parser-0.6.3/token.rs:403:12
    |
403 |     pub fn new<S: Into<Str>>(kind: TokenKind, cont: S, lineno: u32, col_begin: u32) -> Self {
    |            ^^^
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
347 |                         elem.location.row().try_into().unwrap(),
    |                                            ++++++++++++++++++++
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
348 |                         (elem.location.column() - 1).try_into().unwrap(),
    |                         +                          +++++++++++++++++++++

error[E0308]: arguments to this function are incorrect
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/py2erg-0.0.3/convert.rs:369:29
    |
369 |                 let token = Token::new(
    |                             ^^^^^^^^^^
...
372 |                     expr.location.row(),
    |                     ------------------- expected `u32`, found `usize`
373 |                     expr.location.column() - 1,
    |                     -------------------------- expected `u32`, found `usize`
    |
note: associated function defined here
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_parser-0.6.3/token.rs:403:12
    |
403 |     pub fn new<S: Into<Str>>(kind: TokenKind, cont: S, lineno: u32, col_begin: u32) -> Self {
    |            ^^^
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
372 |                     expr.location.row().try_into().unwrap(),
    |                                        ++++++++++++++++++++
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
373 |                     (expr.location.column() - 1).try_into().unwrap(),
    |                     +                          +++++++++++++++++++++

error[E0308]: arguments to this function are incorrect
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/py2erg-0.0.3/convert.rs:404:39
    |
404 |             _other => TypeSpec::Infer(Token::new(
    |                                       ^^^^^^^^^^
...
407 |                 expr.location.row(),
    |                 ------------------- expected `u32`, found `usize`
408 |                 expr.location.column() - 1,
    |                 -------------------------- expected `u32`, found `usize`
    |
note: associated function defined here
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_parser-0.6.3/token.rs:403:12
    |
403 |     pub fn new<S: Into<Str>>(kind: TokenKind, cont: S, lineno: u32, col_begin: u32) -> Self {
    |            ^^^
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
407 |                 expr.location.row().try_into().unwrap(),
    |                                    ++++++++++++++++++++
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
408 |                 (expr.location.column() - 1).try_into().unwrap(),
    |                 +                          +++++++++++++++++++++

error[E0308]: arguments to this function are incorrect
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/py2erg-0.0.3/convert.rs:433:23
    |
433 |         let l_brace = Token::new(l_kind, l_cont, expr_loc.row(), expr_loc.column() - 1);
    |                       ^^^^^^^^^^                 --------------  --------------------- expected `u32`, found `usize`
    |                                                  |
    |                                                  expected `u32`, found `usize`
    |
note: associated function defined here
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_parser-0.6.3/token.rs:403:12
    |
403 |     pub fn new<S: Into<Str>>(kind: TokenKind, cont: S, lineno: u32, col_begin: u32) -> Self {
    |            ^^^
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
433 |         let l_brace = Token::new(l_kind, l_cont, expr_loc.row().try_into().unwrap(), expr_loc.column() - 1);
    |                                                                ++++++++++++++++++++
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
433 |         let l_brace = Token::new(l_kind, l_cont, expr_loc.row(), (expr_loc.column() - 1).try_into().unwrap());
    |                                                                  +                     +++++++++++++++++++++

error[E0308]: arguments to this function are incorrect
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/py2erg-0.0.3/convert.rs:434:23
    |
434 |         let r_brace = Token::new(r_kind, r_cont, l_end, c_end);
    |                       ^^^^^^^^^^                 -----  ----- expected `u32`, found `usize`
    |                                                  |
    |                                                  expected `u32`, found `usize`
    |
note: associated function defined here
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_parser-0.6.3/token.rs:403:12
    |
403 |     pub fn new<S: Into<Str>>(kind: TokenKind, cont: S, lineno: u32, col_begin: u32) -> Self {
    |            ^^^
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
434 |         let r_brace = Token::new(r_kind, r_cont, l_end.try_into().unwrap(), c_end);
    |                                                       ++++++++++++++++++++
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
434 |         let r_brace = Token::new(r_kind, r_cont, l_end, c_end.try_into().unwrap());
    |                                                              ++++++++++++++++++++

error[E0308]: arguments to this function are incorrect
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/py2erg-0.0.3/convert.rs:458:29
    |
458 |                 let token = Token::new(kind, cont, expr.location.row(), expr.location.column() - 1);
    |                             ^^^^^^^^^^             -------------------  -------------------------- expected `u32`, found `usize`
    |                                                    |
    |                                                    expected `u32`, found `usize`
    |
note: associated function defined here
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_parser-0.6.3/token.rs:403:12
    |
403 |     pub fn new<S: Into<Str>>(kind: TokenKind, cont: S, lineno: u32, col_begin: u32) -> Self {
    |            ^^^
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
458 |                 let token = Token::new(kind, cont, expr.location.row().try_into().unwrap(), expr.location.column() - 1);
    |                                                                       ++++++++++++++++++++
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
458 |                 let token = Token::new(kind, cont, expr.location.row(), (expr.location.column() - 1).try_into().unwrap());
    |                                                                         +                          +++++++++++++++++++++

error[E0308]: arguments to this function are incorrect
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/py2erg-0.0.3/convert.rs:467:29
    |
467 |                 let token = Token::new(
    |                             ^^^^^^^^^^
...
470 |                     expr.location.row(),
    |                     ------------------- expected `u32`, found `usize`
471 |                     expr.location.column() - 2,
    |                     -------------------------- expected `u32`, found `usize`
    |
note: associated function defined here
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_parser-0.6.3/token.rs:403:12
    |
403 |     pub fn new<S: Into<Str>>(kind: TokenKind, cont: S, lineno: u32, col_begin: u32) -> Self {
    |            ^^^
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
470 |                     expr.location.row().try_into().unwrap(),
    |                                        ++++++++++++++++++++
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
471 |                     (expr.location.column() - 2).try_into().unwrap(),
    |                     +                          +++++++++++++++++++++

error[E0308]: arguments to this function are incorrect
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/py2erg-0.0.3/convert.rs:475:61
    |
475 |             ExpressionType::False => Expr::Lit(Literal::new(Token::new(
    |                                                             ^^^^^^^^^^
...
478 |                 expr.location.row(),
    |                 ------------------- expected `u32`, found `usize`
479 |                 expr.location.column() - 1,
    |                 -------------------------- expected `u32`, found `usize`
    |
note: associated function defined here
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_parser-0.6.3/token.rs:403:12
    |
403 |     pub fn new<S: Into<Str>>(kind: TokenKind, cont: S, lineno: u32, col_begin: u32) -> Self {
    |            ^^^
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
478 |                 expr.location.row().try_into().unwrap(),
    |                                    ++++++++++++++++++++
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
479 |                 (expr.location.column() - 1).try_into().unwrap(),
    |                 +                          +++++++++++++++++++++

error[E0308]: arguments to this function are incorrect
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/py2erg-0.0.3/convert.rs:481:60
    |
481 |             ExpressionType::True => Expr::Lit(Literal::new(Token::new(
    |                                                            ^^^^^^^^^^
...
484 |                 expr.location.row(),
    |                 ------------------- expected `u32`, found `usize`
485 |                 expr.location.column() - 1,
    |                 -------------------------- expected `u32`, found `usize`
    |
note: associated function defined here
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_parser-0.6.3/token.rs:403:12
    |
403 |     pub fn new<S: Into<Str>>(kind: TokenKind, cont: S, lineno: u32, col_begin: u32) -> Self {
    |            ^^^
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
484 |                 expr.location.row().try_into().unwrap(),
    |                                    ++++++++++++++++++++
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
485 |                 (expr.location.column() - 1).try_into().unwrap(),
    |                 +                          +++++++++++++++++++++

error[E0308]: arguments to this function are incorrect
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/py2erg-0.0.3/convert.rs:487:60
    |
487 |             ExpressionType::None => Expr::Lit(Literal::new(Token::new(
    |                                                            ^^^^^^^^^^
...
490 |                 expr.location.row(),
    |                 ------------------- expected `u32`, found `usize`
491 |                 expr.location.column() - 1,
    |                 -------------------------- expected `u32`, found `usize`
    |
note: associated function defined here
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_parser-0.6.3/token.rs:403:12
    |
403 |     pub fn new<S: Into<Str>>(kind: TokenKind, cont: S, lineno: u32, col_begin: u32) -> Self {
    |            ^^^
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
490 |                 expr.location.row().try_into().unwrap(),
    |                                    ++++++++++++++++++++
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
491 |                 (expr.location.column() - 1).try_into().unwrap(),
    |                 +                          +++++++++++++++++++++

error[E0308]: arguments to this function are incorrect
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/py2erg-0.0.3/convert.rs:493:64
    |
493 |             ExpressionType::Ellipsis => Expr::Lit(Literal::new(Token::new(
    |                                                                ^^^^^^^^^^
...
496 |                 expr.location.row(),
    |                 ------------------- expected `u32`, found `usize`
497 |                 expr.location.column() - 1,
    |                 -------------------------- expected `u32`, found `usize`
    |
note: associated function defined here
   --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_parser-0.6.3/token.rs:403:12
    |
403 |     pub fn new<S: Into<Str>>(kind: TokenKind, cont: S, lineno: u32, col_begin: u32) -> Self {
    |            ^^^
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
496 |                 expr.location.row().try_into().unwrap(),
    |                                    ++++++++++++++++++++
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
    |
497 |                 (expr.location.column() - 1).try_into().unwrap(),
    |                 +                          +++++++++++++++++++++

error[E0308]: mismatched types
    --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/py2erg-0.0.3/convert.rs:805:86
     |
805  |             Identifier::public_with_line(DOT, self.namespace.last().unwrap().into(), line);
     |             ---------------------------- arguments to this function are incorrect    ^^^^ expected `u32`, found `usize`
     |
note: associated function defined here
    --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_parser-0.6.3/ast.rs:2434:12
     |
2434 |     pub fn public_with_line(dot: Token, name: Str, line: u32) -> Self {
     |            ^^^^^^^^^^^^^^^^
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
     |
805  |             Identifier::public_with_line(DOT, self.namespace.last().unwrap().into(), line.try_into().unwrap());
     |                                                                                          ++++++++++++++++++++

error[E0308]: mismatched types
    --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/py2erg-0.0.3/convert.rs:999:75
     |
999  | ...                   VarName::from_str_and_line((&tmp).into(), stmt.location.row());
     |                       --------------------------                ^^^^^^^^^^^^^^^^^^^ expected `u32`, found `usize`
     |                       |
     |                       arguments to this function are incorrect
     |
note: associated function defined here
    --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_parser-0.6.3/ast.rs:2320:12
     |
2320 |     pub fn from_str_and_line(symbol: Str, line: u32) -> Self {
     |            ^^^^^^^^^^^^^^^^^
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
     |
999  |                                 VarName::from_str_and_line((&tmp).into(), stmt.location.row().try_into().unwrap());
     |                                                                                              ++++++++++++++++++++

error[E0308]: arguments to this function are incorrect
    --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/py2erg-0.0.3/convert.rs:1014:58
     |
1014 | ...                   let index = Literal::new(Token::new(
     |                                                ^^^^^^^^^^
...
1017 | ...                       elem.location.row(),
     |                           ------------------- expected `u32`, found `usize`
1018 | ...                       elem.location.column() - 1,
     |                           -------------------------- expected `u32`, found `usize`
     |
note: associated function defined here
    --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_parser-0.6.3/token.rs:403:12
     |
403  |     pub fn new<S: Into<Str>>(kind: TokenKind, cont: S, lineno: u32, col_begin: u32) -> Self {
     |            ^^^
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
     |
1017 |                                     elem.location.row().try_into().unwrap(),
     |                                                        ++++++++++++++++++++
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
     |
1018 |                                     (elem.location.column() - 1).try_into().unwrap(),
     |                                     +                          +++++++++++++++++++++

error[E0308]: arguments to this function are incorrect
    --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/py2erg-0.0.3/convert.rs:1267:59
     |
1267 |                     let mod_name = Expr::Lit(Literal::new(Token::new(
     |                                                           ^^^^^^^^^^
...
1270 |                         stmt.location.row(),
     |                         ------------------- expected `u32`, found `usize`
1271 |                         stmt.location.column() - 1,
     |                         -------------------------- expected `u32`, found `usize`
     |
note: associated function defined here
    --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_parser-0.6.3/token.rs:403:12
     |
403  |     pub fn new<S: Into<Str>>(kind: TokenKind, cont: S, lineno: u32, col_begin: u32) -> Self {
     |            ^^^
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
     |
1270 |                         stmt.location.row().try_into().unwrap(),
     |                                            ++++++++++++++++++++
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
     |
1271 |                         (stmt.location.column() - 1).try_into().unwrap(),
     |                         +                          +++++++++++++++++++++

error[E0308]: arguments to this function are incorrect
    --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/py2erg-0.0.3/convert.rs:1309:55
     |
1309 |                 let mod_name = Expr::Lit(Literal::new(Token::new(
     |                                                       ^^^^^^^^^^
...
1312 |                     stmt.location.row(),
     |                     ------------------- expected `u32`, found `usize`
1313 |                     stmt.location.column() - 1,
     |                     -------------------------- expected `u32`, found `usize`
     |
note: associated function defined here
    --> /Users/boxed/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_parser-0.6.3/token.rs:403:12
     |
403  |     pub fn new<S: Into<Str>>(kind: TokenKind, cont: S, lineno: u32, col_begin: u32) -> Self {
     |            ^^^
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
     |
1312 |                     stmt.location.row().try_into().unwrap(),
     |                                        ++++++++++++++++++++
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
     |
1313 |                     (stmt.location.column() - 1).try_into().unwrap(),
     |                     +                          +++++++++++++++++++++

For more information about this error, try `rustc --explain E0308`.
error: could not compile `py2erg` due to 23 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to compile `pylyzer v0.0.3`, intermediate artifacts can be found at `/var/folders/p_/lmszy5p567g8g7mth15yhz3m0000gn/T/cargo-installC3Enfv`

Installing pylyzer through Mason does not work (Neovim)

When I try to install pylyzer through Mason does not seem to work

MasonLog: [ERROR Thu May 11 10:14:39 2023] ...e/nvim/lazy/mason.nvim/lua/mason-core/installer/init.lua:200: Installation failed for Package(name=pylyzer) error=spawn: cargo failed with exit code 101 and signal 0.

Neovim version: 0.9.0
Operating system: Ventura 13 (MacOS M1)

Maybe this is something on my end that I am doing wrong

Screenshot 2023-05-11 at 10 35 10

diagnostics not showing up in neovim-nightly

image

I expect error diagnostics to show up for the bottom two lines.

Doing this from the command line pylyzer add_one.py gives the following:
image

configs are from kickstart.nvim:

--  NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '

-- Install package manager
--    https://github.com/folke/lazy.nvim
--    `:help lazy.nvim.txt` for more info
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system {
    'git',
    'clone',
    '--filter=blob:none',
    'https://github.com/folke/lazy.nvim.git',
    '--branch=stable', -- latest stable release
    lazypath,
  }
end
vim.opt.rtp:prepend(lazypath)

-- NOTE: Here is where you install your plugins.
--  You can configure plugins using the `config` key.
--
--  You can also configure plugins after the setup call,
--    as they will be available in your neovim runtime.
require('lazy').setup({
  -- NOTE: First, some plugins that don't require any configuration

  -- Git related plugins
  'tpope/vim-fugitive',
  'tpope/vim-rhubarb',

  -- Detect tabstop and shiftwidth automatically
  'tpope/vim-sleuth',

  -- NOTE: This is where your plugins related to LSP can be installed.
  --  The configuration is done below. Search for lspconfig to find it below.
  {
    -- LSP Configuration & Plugins
    'neovim/nvim-lspconfig',
    dependencies = {
      -- Automatically install LSPs to stdpath for neovim
      { 'williamboman/mason.nvim', config = true },
      'williamboman/mason-lspconfig.nvim',

      -- Useful status updates for LSP
      -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
      { 'j-hui/fidget.nvim', opts = {} },

      -- Additional lua configuration, makes nvim stuff amazing!
      'folke/neodev.nvim',
    },
  },

  {
    -- Autocompletion
    'hrsh7th/nvim-cmp',
    dependencies = {
      -- Snippet Engine & its associated nvim-cmp source
      'L3MON4D3/LuaSnip',
      'saadparwaiz1/cmp_luasnip',

      -- Adds LSP completion capabilities
      'hrsh7th/cmp-nvim-lsp',

      -- Adds a number of user-friendly snippets
      'rafamadriz/friendly-snippets',
    },
  },

  {'lvimuser/lsp-inlayhints.nvim'},

  -- Useful plugin to show you pending keybinds.
  { 'folke/which-key.nvim', opts = {} },
  {
    -- Adds git releated signs to the gutter, as well as utilities for managing changes
    'lewis6991/gitsigns.nvim',
    opts = {
      -- See `:help gitsigns.txt`
      signs = {
        add = { text = '+' },
        change = { text = '~' },
        delete = { text = '_' },
        topdelete = { text = '‾' },
        changedelete = { text = '~' },
      },
      on_attach = function(bufnr)
        vim.keymap.set('n', '[c', require('gitsigns').prev_hunk, { buffer = bufnr, desc = 'Go to Previous Hunk' })
        vim.keymap.set('n', ']c', require('gitsigns').next_hunk, { buffer = bufnr, desc = 'Go to Next Hunk' })
        vim.keymap.set('n', '<leader>ph', require('gitsigns').preview_hunk, { buffer = bufnr, desc = '[P]review [H]unk' })
      end,
    },
  },

  {
    -- Theme inspired by Atom
    'navarasu/onedark.nvim',
    priority = 1000,
    config = function()
      vim.cmd.colorscheme 'onedark'
    end,
  },

  {
    -- Set lualine as statusline
    'nvim-lualine/lualine.nvim',
    -- See `:help lualine.txt`
    opts = {
      options = {
        icons_enabled = false,
        theme = 'onedark',
        component_separators = '|',
        section_separators = '',
      },
    },
  },

  {
    -- Add indentation guides even on blank lines
    'lukas-reineke/indent-blankline.nvim',
    -- Enable `lukas-reineke/indent-blankline.nvim`
    -- See `:help indent_blankline.txt`
    opts = {
      char = '┊',
      show_trailing_blankline_indent = false,
    },
  },

  -- "gc" to comment visual regions/lines
  { 'numToStr/Comment.nvim', opts = {} },

  -- Fuzzy Finder (files, lsp, etc)
  { 'nvim-telescope/telescope.nvim', branch = '0.1.x', dependencies = { 'nvim-lua/plenary.nvim' } },

  -- Fuzzy Finder Algorithm which requires local dependencies to be built.
  -- Only load if `make` is available. Make sure you have the system
  -- requirements installed.
  {
    'nvim-telescope/telescope-fzf-native.nvim',
    -- NOTE: If you are having trouble with this installation,
    --       refer to the README for telescope-fzf-native for more instructions.
    build = 'make',
    cond = function()
      return vim.fn.executable 'make' == 1
    end,
  },

  {
    -- Highlight, edit, and navigate code
    'nvim-treesitter/nvim-treesitter',
    dependencies = {
      'nvim-treesitter/nvim-treesitter-textobjects',
    },
    build = ':TSUpdate',
  },

  -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
  --       These are some example plugins that I've included in the kickstart repository.
  --       Uncomment any of the lines below to enable them.
  -- require 'kickstart.plugins.autoformat',
  -- require 'kickstart.plugins.debug',

  -- NOTE: The import below automatically adds your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
  --    You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping
  --    up-to-date with whatever is in the kickstart repo.
  --
  --    For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins
  -- { import = 'custom.plugins' },
}, {})

-- [[ Setting options ]]
-- See `:help vim.o`
-- NOTE: You can change these options as you wish!

-- Set highlight on search
vim.o.hlsearch = false

-- Make line numbers default
vim.wo.number = true

-- Enable mouse mode
vim.o.mouse = 'a'

-- Sync clipboard between OS and Neovim.
--  Remove this option if you want your OS clipboard to remain independent.
--  See `:help 'clipboard'`
vim.o.clipboard = 'unnamedplus'

-- Enable break indent
vim.o.breakindent = true

-- Save undo history
vim.o.undofile = true

-- Case insensitive searching UNLESS /C or capital in search
vim.o.ignorecase = true
vim.o.smartcase = true

-- Keep signcolumn on by default
vim.wo.signcolumn = 'yes'

-- Decrease update time
vim.o.updatetime = 250
vim.o.timeout = true
vim.o.timeoutlen = 300

-- Set completeopt to have a better completion experience
vim.o.completeopt = 'menuone,noselect'

-- NOTE: You should make sure your terminal supports this
vim.o.termguicolors = true

-- [[ Basic Keymaps ]]

-- Keymaps for better default experience
-- See `:help vim.keymap.set()`
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })

-- Remap for dealing with word wrap
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })

-- [[ Highlight on yank ]]
-- See `:help vim.highlight.on_yank()`
local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
vim.api.nvim_create_autocmd('TextYankPost', {
  callback = function()
    vim.highlight.on_yank()
  end,
  group = highlight_group,
  pattern = '*',
})

-- [[ Configure Telescope ]]
-- See `:help telescope` and `:help telescope.setup()`
require('telescope').setup {
  defaults = {
    mappings = {
      i = {
        ['<C-u>'] = false,
        ['<C-d>'] = false,
      },
    },
  },
}

-- Enable telescope fzf native, if installed
pcall(require('telescope').load_extension, 'fzf')

-- See `:help telescope.builtin`
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' })
vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
vim.keymap.set('n', '<leader>/', function()
  -- You can pass additional configuration to telescope to change theme, layout, etc.
  require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
    winblend = 10,
    previewer = false,
  })
end, { desc = '[/] Fuzzily search in current buffer' })

vim.keymap.set('n', '<leader>gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' })
vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })

-- [[ Configure Treesitter ]]
-- See `:help nvim-treesitter`
require('nvim-treesitter.configs').setup {
  -- Add languages to be installed here that you want installed for treesitter
  ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'vimdoc', 'vim' },

  -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
  auto_install = false,

  highlight = { enable = true },
  indent = { enable = true, disable = { 'python' } },
  incremental_selection = {
    enable = true,
    keymaps = {
      init_selection = '<c-space>',
      node_incremental = '<c-space>',
      scope_incremental = '<c-s>',
      node_decremental = '<M-space>',
    },
  },
  textobjects = {
    select = {
      enable = true,
      lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
      keymaps = {
        -- You can use the capture groups defined in textobjects.scm
        ['aa'] = '@parameter.outer',
        ['ia'] = '@parameter.inner',
        ['af'] = '@function.outer',
        ['if'] = '@function.inner',
        ['ac'] = '@class.outer',
        ['ic'] = '@class.inner',
      },
    },
    move = {
      enable = true,
      set_jumps = true, -- whether to set jumps in the jumplist
      goto_next_start = {
        [']m'] = '@function.outer',
        [']]'] = '@class.outer',
      },
      goto_next_end = {
        [']M'] = '@function.outer',
        [']['] = '@class.outer',
      },
      goto_previous_start = {
        ['[m'] = '@function.outer',
        ['[['] = '@class.outer',
      },
      goto_previous_end = {
        ['[M'] = '@function.outer',
        ['[]'] = '@class.outer',
      },
    },
    swap = {
      enable = true,
      swap_next = {
        ['<leader>a'] = '@parameter.inner',
      },
      swap_previous = {
        ['<leader>A'] = '@parameter.inner',
      },
    },
  },
}

-- Diagnostic keymaps
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })

-- [[ Configure LSP ]]
--  This function gets run when an LSP connects to a particular buffer.
local on_attach = function(client, bufnr)
  -- NOTE: Remember that lua is a real programming language, and as such it is possible
  -- to define small helper and utility functions so you don't have to repeat yourself
  -- many times.
  --
  -- In this case, we create a function that lets us more easily define mappings specific
  -- for LSP related items. It sets the mode, buffer and description for us each time.
  require("lsp-inlayhints").on_attach(client, bufnr, false)
  local nmap = function(keys, func, desc)
    if desc then
      desc = 'LSP: ' .. desc
    end

    vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
  end

  nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
  nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')

  nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
  nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
  nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation')
  nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
  nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
  nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')

  -- See `:help K` for why this keymap
  nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
  nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')

  -- Lesser used LSP functionality
  nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
  nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
  nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
  nmap('<leader>wl', function()
    print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
  end, '[W]orkspace [L]ist Folders')

  -- Create a command `:Format` local to the LSP buffer
  vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
    vim.lsp.buf.format()
  end, { desc = 'Format current buffer with LSP' })
end

-- Enable the following language servers
--  Feel free to add/remove any LSPs that you want here. They will automatically be installed.
--
--  Add any additional override configuration in the following tables. They will be passed to
--  the `settings` field of the server config. You must look up that documentation yourself.
local servers = {
  pylyzer = {},
}

-- Setup neovim lua configuration
require('neodev').setup()

-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)

-- Ensure the servers above are installed
local mason_lspconfig = require 'mason-lspconfig'

mason_lspconfig.setup {
  ensure_installed = vim.tbl_keys(servers),
}

mason_lspconfig.setup_handlers {
  function(server_name)
    require('lspconfig')[server_name].setup {
      capabilities = capabilities,
      on_attach = on_attach,
      settings = servers[server_name],
    }
  end,
}

-- [[ Configure nvim-cmp ]]
-- See `:help cmp`
local cmp = require 'cmp'
local luasnip = require 'luasnip'
require('luasnip.loaders.from_vscode').lazy_load()
luasnip.config.setup {}

cmp.setup {
  snippet = {
    expand = function(args)
      luasnip.lsp_expand(args.body)
    end,
  },
  mapping = cmp.mapping.preset.insert {
    ['<C-n>'] = cmp.mapping.select_next_item(),
    ['<C-p>'] = cmp.mapping.select_prev_item(),
    ['<C-d>'] = cmp.mapping.scroll_docs(-4),
    ['<C-f>'] = cmp.mapping.scroll_docs(4),
    ['<C-Space>'] = cmp.mapping.complete {},
    ['<CR>'] = cmp.mapping.confirm {
      behavior = cmp.ConfirmBehavior.Replace,
      select = true,
    },
    ['<Tab>'] = cmp.mapping(function(fallback)
      if cmp.visible() then
        cmp.select_next_item()
      elseif luasnip.expand_or_locally_jumpable() then
        luasnip.expand_or_jump()
      else
        fallback()
      end
    end, { 'i', 's' }),
    ['<S-Tab>'] = cmp.mapping(function(fallback)
      if cmp.visible() then
        cmp.select_prev_item()
      elseif luasnip.locally_jumpable(-1) then
        luasnip.jump(-1)
      else
        fallback()
      end
    end, { 'i', 's' }),
  },
  sources = {
    { name = 'nvim_lsp' },
    { name = 'luasnip' },
  },
}

-- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et

Compilation error in ELS dependency

Hi, when attempting compilation of 0.0.24 on arch, the following error is thrown:

   Compiling els v0.1.24-nightly.4
error: `char::methods::<impl char>::from_u32` is not yet stable as a const fn
   --> /home/nb/.cargo/registry/src/github.com-1ecc6299db9ec823/els-0.1.24-nightly.4/completion.rs:96:38
    |
96  |       pub const STD_ITEM: char = match char::from_u32(
    |  ______________________________________^
97  | |         CompletionOrder::Normal as u32
98  | |             + CompletionOrder::Builtin as u32
99  | |             + CompletionOrder::OtherNamespace as u32,
100 | |     ) {
    | |_____^

error: could not compile `els` due to previous error
warning: build failed, waiting for other jobs to finish...

Just to understand correctly, this is an error in the els library correct? if so, please close and ill look into it and notify the els people :)

thank you so much for the tool!

Error in importing from abc

I get this error:

module abc not found
similar name python module exits: abc
hint: to import python modules, use pyimport (not import)

Broken on Windows

After pip install pylyzer there seems to be a dependency on an installed cargo build environment or such:

thread '<unnamed>' panicked at 'ERG_PATH not found: Os { code: 3, kind: NotFound, message: "Das System kann den angegebenen Pfad nicht finden." }', C:\Users\sbym8\.cargo\registry\src\github.com-1ecc6299db9ec823\erg_common-0.6.7-nightly.2\env.rs:10:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Any { .. }', C:\Users\sbym8\.cargo\registry\src\github.com-1ecc6299db9ec823\erg_common-0.6.7-nightly.2\spawn.rs:31:22

pylyzer should report relative file path in original case

I'm using neovim with plugin like telescope and trouble,
pylyzer is installed with mason as lsp server.

pylyzer installed version: 0.0.31
my neovim config: lazyNvim

  • here is an case

    mkdir Ac
    cat >>Ac/tesT.py <<EOF
    import os
    abc = defg
    EOF
    
    # open with nvim
    nvim Ac/tesT.py
    

    within nvim, check lsp info with :LspInfo, get:

     ..
    Config: pylyzer
        filetypes:         python
        root directory:    Not found.
    ..
    

    pylyzer seems not load at the time as root directory not found,
    while pyright run in single file mode by default for the case

    to load pylyzer, run: touch Ac/pyproject.toml, then open the
    py file with nvim Ac/tesT.py, pylyzer should run with a known root directory.

    within nvim, check the diagnostic list with :TroubleToggle

    diagnostic window

    the last item is reported by pylyzer, and the reported path is 'ac/test.py' which should be 'Ac/tesT.py', for which preview with trouble or telescope will fail for unable to find the file.

    then exit nvim and change dir: cd Ac; nvim tesT.py, check again
    diagnostic window after cd

    pylyzer use full path in lowered case, while pyright use relative path, and the same issue for other tools.

  • the issue

    1. pylyzer report with lower cased path, relative path with orignal case should be fine
    2. pylyzer seems to analyze with file instead of the buffer content, for which without save to file, the report will not update

Change the parser to something better

Currently, pylyzer uses rustpython-parser to parse Python code. However, this parser does not give detailed location information for each token. We will need to change to a better parser or create our own.

AttributeError: PyModule("typing") object has no attribute Mapping

Very excited for this project so just trying it out. Apologies if I'm doing something wrong since I'm just getting started. Consider the following small file:

from typing import Mapping

With pylyzer 0.0.25 I get the errors:

Error[#0179]: File tmp.py, line 1, <module>.Mapping

1 | from typing import Mapping
  :                    -----

NotConstExpr: not a constant expression

Error[#0624]: File tmp3.py, line 1, <module>.Mapping

1 | from typing import Mapping
  :                    -------

AttributeError: PyModule("typing") object has no attribute Mapping

running

pylyzer tmp.py

"No such file or directory" when running 0.0.33

Error:

[ERROR][2023-07-02 01:17:35] .../vim/lsp/rpc.lua:734	"rpc"	"pylyzer"	"stderr"	"thread 'pylyzer' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: \"No such file or directory\" }', /home/adam/.cargo/registry/src/index.crates.io-6f17d22bba15001f/erg_compiler-0.6.16-nightly.3/module/global.rs:44:70\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\nThread panicked: Any { .. }\n"

Running 0.0.33, installed via mason on nvim. Using default config from nvim-lspconfig

failed to install using cargo

environment:

  • linux dist: debian testing
  • cargo: 1.65.0
  • rustc: 1.63.0

log of cargo install pylyzer:

      Updating `tuna` index
    Installing pylyzer v0.0.27
     Compiling autocfg v1.1.0
     Compiling libc v0.2.144
     Compiling proc-macro2 v1.0.58
     Compiling unicode-ident v1.0.8
     Compiling quote v1.0.27
     Compiling rand_core v0.4.2
     Compiling serde v1.0.163
     Compiling siphasher v0.2.3
     Compiling typenum v1.16.0
     Compiling memchr v2.5.0
     Compiling log v0.4.17
     Compiling erg_common v0.6.13-nightly.4
     Compiling string_cache_shared v0.3.0
     Compiling byteorder v1.4.3
     Compiling byte-tools v0.3.1
     Compiling block-padding v0.1.5
     Compiling lazy_static v1.4.0
     Compiling regex-syntax v0.7.1
     Compiling cfg-if v1.0.0
     Compiling precomputed-hash v0.1.1
     Compiling autocfg v0.1.8
     Compiling rand_core v0.3.1
     Compiling rand_jitter v0.1.4
     Compiling rand_xorshift v0.1.1
     Compiling rand_isaac v0.1.1
     Compiling rand_hc v0.1.0
     Compiling phf_shared v0.7.24
     Compiling tinyvec_macros v0.1.1
     Compiling strsim v0.10.0
     Compiling ordermap v0.3.5
     Compiling bit-vec v0.6.3
     Compiling opaque-debug v0.2.3
     Compiling fixedbitset v0.1.9
     Compiling rand_pcg v0.1.2
     Compiling rand_chacha v0.1.1
     Compiling rand v0.6.5
     Compiling num-traits v0.2.15
     Compiling new_debug_unreachable v1.0.4
     Compiling either v1.8.1
     Compiling fake-simd v0.1.2
     Compiling bit-set v0.5.3
     Compiling itertools v0.8.2
     Compiling ena v0.13.1
     Compiling num-integer v0.1.45
     Compiling petgraph v0.4.13
     Compiling tinyvec v1.6.0
     Compiling regex-syntax v0.6.29
     Compiling lalrpop-util v0.17.2
     Compiling unicode-xid v0.1.0
     Compiling unic-common v0.9.0
     Compiling aho-corasick v1.0.1
     Compiling diff v0.1.13
     Compiling unic-char-range v0.9.0
     Compiling unic-char-property v0.9.0
     Compiling unic-ucd-version v0.9.0
     Compiling num-bigint v0.2.6
     Compiling syn v2.0.16
     Compiling unicode-bidi v0.3.13
     Compiling serde_json v1.0.96
     Compiling rand_os v0.1.3
     Compiling dirs v1.0.5
     Compiling atty v0.2.14
     Compiling term v0.5.2
  error[E0658]: `let...else` statements are unstable
     --> /home/yaowj/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/erg_common-0.6.13-nightly.4/error.rs:368:9
      |
  368 | /         let Some(last_known) = ls.iter().rev().find(|l| !l.loc().is_unknown()) else {
  369 | |             return Self::Unknown;
  370 | |         };
      | |__________^
      |
      = note: see issue #87335 <https://github.com/rust-lang/rust/issues/87335> for more information
  
  error[E0658]: `let...else` statements are unstable
     --> /home/yaowj/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/erg_common-0.6.13-nightly.4/error.rs:365:9
      |
  365 | /         let Some(first_known) = ls.iter().find(|l| !l.loc().is_unknown()) else {
  366 | |             return Self::Unknown;
  367 | |         };
      | |__________^
      |
      = note: see issue #87335 <https://github.com/rust-lang/rust/issues/87335> for more information
  
  error[E0658]: `let...else` statements are unstable
    --> /home/yaowj/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/erg_common-0.6.13-nightly.4/tsort.rs:75:5
     |
  75 | /     let Some(vertex) = g.iter().find(|n| n.id == v) else {
  76 | |         return Err(TopoSortError::KeyNotFound);
  77 | |     };
     | |______^
     |
     = note: see issue #87335 <https://github.com/rust-lang/rust/issues/87335> for more information
  
     Compiling generic-array v0.12.4
     Compiling unicode-xid v0.2.4
     Compiling percent-encoding v2.2.0
     Compiling form_urlencoded v1.1.0
     Compiling unicode-normalization v0.1.22
     Compiling ascii-canvas v2.0.0
     Compiling block-buffer v0.7.3
     Compiling digest v0.8.1
     Compiling sha2 v0.8.2
     Compiling itoa v1.0.6
  For more information about this error, try `rustc --explain E0658`.
  error: could not compile `erg_common` due to 3 previous errors
  warning: build failed, waiting for other jobs to finish...
  error: could not compile `erg_common` due to 3 previous errors
  error: failed to compile `pylyzer v0.0.27`, intermediate artifacts can be found at `/tmp/cargo-installcddxr3`

Help command broken

> pylyzer --help
invalid option: --help

USAGE:
pylyzer [OPTIONS] [SUBCOMMAND] [ARGS]...

For more information try `pylyzer --help`

Reaching too deep in import resolution

Hello
Look like pylyzer is missing limit on nesting import and in complex projects with multiple imports crawling even into std library and crashes there:

Start checking: main.py
...
Start checking: common.py
Start checking: getpass.py
Start checking: contextlib.py
thread 'main' panicked at 'internal error: entered unreachable code', /Users/pasteley/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_compiler-0.6.14-nightly.0/declare.rs:299:43
stack backtrace:
   0:        0x100ff1bd8 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h554558af9dcaf5d8
   1:        0x101008c6c - core::fmt::write::h503a82454aa26fb4
   2:        0x100fd771c - std::io::Write::write_fmt::he97d6853eddb17d2
   3:        0x100ff19e8 - std::sys_common::backtrace::print::h669032be8d7b2a7c
   4:        0x100fdef74 - std::panicking::default_hook::{{closure}}::h974276930a474e6a
   5:        0x100fdec38 - std::panicking::default_hook::hb0d2c45a1e792803
   6:        0x100fdf660 - std::panicking::rust_panic_with_hook::hf3b9a3e44fe5f275
   7:        0x100ff2564 - std::panicking::begin_panic_handler::{{closure}}::ha19c90e1160a0cf9
   8:        0x100ff1d18 - std::sys_common::backtrace::__rust_end_short_backtrace::h3f85ad00ac73ff55
   9:        0x100fdf2c0 - _rust_begin_unwind
  10:        0x1010282f0 - core::panicking::panic_fmt::hb0625f6d6e3c09e4
  11:        0x101028360 - core::panicking::panic::h53789822e3a49a18
  12:        0x100e8785c - erg_compiler::declare::<impl erg_compiler::lower::ASTLowerer>::fake_lower_record::ha20de20df591ac8e
  13:        0x100e8aff4 - erg_compiler::declare::<impl erg_compiler::lower::ASTLowerer>::fake_lower_expr::he816d1c4bd79d283
  14:        0x100e84454 - erg_compiler::declare::<impl erg_compiler::lower::ASTLowerer>::fake_lower_call::hf734f43d62012ba1
  15:        0x100e8b1a4 - erg_compiler::declare::<impl erg_compiler::lower::ASTLowerer>::fake_lower_expr::he816d1c4bd79d283
  16:        0x100e89518 - erg_compiler::declare::<impl erg_compiler::lower::ASTLowerer>::fake_lower_params::h28f7bb1ce0b93ae2
  17:        0x100e89c6c - erg_compiler::declare::<impl erg_compiler::lower::ASTLowerer>::fake_lower_lambda::hed460f2cc6e6a353
  18:        0x100e8a8f8 - erg_compiler::declare::<impl erg_compiler::lower::ASTLowerer>::fake_lower_expr::he816d1c4bd79d283
  19:        0x100e8f868 - erg_compiler::declare::<impl erg_compiler::lower::ASTLowerer>::declare_chunk::h42d8bcee330b1beb
  20:        0x100eb043c - erg_compiler::lower::ASTLowerer::lower::h3e04e12f3a1abaeb
  21:        0x100cdffb0 - erg_compiler::build_hir::HIRBuilder::check::h922dbb9789094412
  22:        0x100ce0650 - erg_compiler::build_hir::HIRBuilder::build::hcbd850acbd86e40d
  23:        0x100aa964c - erg_compiler::context::register::<impl erg_compiler::context::Context>::import_mod::h2687e447b2540cfe
  24:        0x100a9ac88 - erg_compiler::context::register::<impl erg_compiler::context::Context>::pre_import::h4ae4d60ff811f652
  25:        0x100a9a8d0 - erg_compiler::context::register::<impl erg_compiler::context::Context>::preregister::h8ff905bceed9eff6
  26:        0x100a9aa50 - erg_compiler::context::register::<impl erg_compiler::context::Context>::preregister::h8ff905bceed9eff6
  27:        0x100eaf9dc - erg_compiler::lower::ASTLowerer::lower::h3e04e12f3a1abaeb
  28:        0x100643fc4 - pylyzer::analyze::PythonAnalyzer::analyze::h5c77832e944fb36a
  29:        0x100644590 - pylyzer::analyze::PythonAnalyzer::run::h85da60a830225d40
  30:        0x1005ab174 - pylyzer::run::h2f5214ce5dcb8f89
  31:        0x100635934 - std::sys_common::backtrace::__rust_begin_short_backtrace::hc9c79afbcee17da6
  32:        0x100653fbc - std::rt::lang_start::{{closure}}::h9d9343ced2be4d6a
  33:        0x100fdd9cc - std::rt::lang_start_internal::h2a63b0d73f6d9885
  34:        0x1005ab258 - _main

os: macOS 13.1
pylyzer: 0.0.29
python: 3.10.7

Stack overflow

I have a relatively small Python program that I tried running pylyzer on. In (and outside) my virtual enviroment I execute pylyzer /path/to/project/main_of_project.py and I get:

cannot open '/path/to/project/source/utils/dependency1.py': [Errno 2] No such file or directory (os error 2)
cannot open '/path/to/project/source/utils/dependency2.py': [Errno 2] No such file or directory (os error 2)
cannot open '/path/to/project/source/dependency3.py': [Errno 2] No such file or directory (os error 2)
cannot open '/path/to/project/source/dependency4.py': [Errno 2] No such file or directory (os error 2)
cannot open '/path/to/project/source/dependency5.py': [Errno 2] No such file or directory (os error 2)

thread 'main' has overflowed its stack
fatal runtime error: stack overflow
Aborted (core dumped)

All dependency files are of course available.

  • Python: 3.11
  • OS: Kubuntu 23.04 x86_64
  • Kernel: 6.2.0-20-generic
  • Pylyzer: 0.0.27

Highlight issues

pylyzer 0.3.1
neovim 9.1.1
MacOS/Linux

No errors/messages in LSP logs
pylyzer is runned.
The help of function is mutch better now - thanks
But some fitches don't work again

image

On import ans function args the same colors (in jedy/pyright is different)
And next two line with out of range - but pylyzer dont show errors.

From day to day pylyzer is better. In we are wait for first stable release that can work with it. Because its impossible at this time, but we are try to make fidback :)

Failure to install with cargo

Thanks for the interesting project! Unfortunately, I'm now running into issues installing pylyzer via cargo:

❯ cargo install pylyzer
    Updating crates.io index
  Installing pylyzer v0.0.43
    Updating crates.io index
   Compiling libc v0.2.147
   Compiling proc-macro2 v1.0.66
   Compiling unicode-ident v1.0.11
   Compiling autocfg v1.1.0
   Compiling cfg-if v1.0.0
   Compiling typenum v1.16.0
   Compiling version_check v0.9.4
   Compiling syn v1.0.109
   Compiling parking_lot_core v0.9.8
   Compiling getrandom v0.1.16
   Compiling ryu v1.0.15
   Compiling block-padding v0.2.1
   Compiling erg_common v0.6.20
   Compiling generic-array v0.14.7
   Compiling lock_api v0.4.10
   Compiling either v1.9.0
   Compiling ppv-lite86 v0.2.17
   Compiling once_cell v1.18.0
   Compiling opaque-debug v0.3.0
   Compiling keccak v0.1.4
   Compiling itertools v0.9.0
   Compiling quote v1.0.33
   Compiling rand_core v0.5.1
   Compiling syn v2.0.31
   Compiling smallvec v1.11.0
   Compiling base64 v0.13.1
   Compiling rand_chacha v0.2.2
   Compiling scopeguard v1.2.0
   Compiling rand v0.7.3
   Compiling num-traits v0.2.16
   Compiling tinyvec_macros v0.1.1
   Compiling block-buffer v0.9.0
   Compiling digest v0.9.0
   Compiling siphasher v0.3.11
   Compiling rand_core v0.6.4
   Compiling sha3 v0.9.1
   Compiling crunchy v0.2.2
   Compiling serde v1.0.188
   Compiling thread_local v1.1.7
   Compiling rand v0.8.5
   Compiling phf_shared v0.11.2
   Compiling malachite-base v0.3.2
   Compiling tinyvec v1.6.0
   Compiling parking_lot v0.12.1
   Compiling num-integer v0.1.45
   Compiling anyhow v1.0.75
   Compiling paste v1.0.14
   Compiling tiny-keccak v2.0.2
   Compiling phf_generator v0.11.2
   Compiling unicode-normalization v0.1.22
   Compiling unicode-bidi v0.3.13
   Compiling serde_derive v1.0.188
   Compiling unic-char-range v0.9.0
   Compiling convert_case v0.4.0
   Compiling unic-common v0.9.0
   Compiling percent-encoding v2.3.0
   Compiling pmutil v0.5.3
   Compiling serde_json v1.0.105
   Compiling memchr v2.6.3
   Compiling Inflector v0.11.4
   Compiling form_urlencoded v1.2.0
   Compiling erg_compiler v0.6.20
   Compiling unic-ucd-version v0.9.0
   Compiling unic-char-property v0.9.0
   Compiling rustpython-parser-vendored v0.3.0
   Compiling idna v0.4.0
   Compiling phf_codegen v0.11.2
   Compiling unicode-xid v0.2.4
   Compiling itoa v1.0.9
   Compiling rustpython-parser v0.3.0
   Compiling erg_parser v0.6.20
   Compiling serde_repr v0.1.16
   Compiling static_assertions v1.1.0
   Compiling bitflags v1.3.2
   Compiling phf v0.11.2
   Compiling unic-emoji-char v0.9.0
   Compiling unic-ucd-ident v0.9.0
   Compiling itertools v0.10.5
   Compiling embed-doc-image v0.1.4
   Compiling is-macro v0.2.2
   Compiling derive_more v0.99.17
   Compiling lalrpop-util v0.20.0
   Compiling log v0.4.20
   Compiling rustc-hash v1.1.0
   Compiling unicode_names2 v0.6.0
   Compiling rustpython-parser-core v0.3.0
   Compiling url v2.4.1
   Compiling malachite-nz v0.3.2
   Compiling lsp-types v0.93.2
   Compiling malachite-q v0.3.2
   Compiling malachite v0.3.2
   Compiling malachite-bigint v0.1.0
   Compiling rustpython-ast v0.3.0
   Compiling molc v0.1.0
   Compiling els v0.1.32
   Compiling py2erg v0.0.43
   Compiling pylyzer v0.0.43
error[E0061]: this function takes 2 arguments but 1 argument was supplied
   --> /home/wil/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pylyzer-0.0.43/src/main.rs:13:31
    |
13  |         let mut lang_server = Server::<PythonAnalyzer, SimplePythonParser>::new(cfg);
    |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----- an argument of type `Option<Sender<serde_json::value::Value>>` is missing
    |
note: associated function defined here
   --> /home/wil/.cargo/registry/src/index.crates.io-6f17d22bba15001f/els-0.1.32/server.rs:330:12
    |
330 |     pub fn new(cfg: ErgConfig, stdout_redirect: Option<mpsc::Sender<Value>>) -> Self {
    |            ^^^
help: provide the argument
    |
13  |         let mut lang_server = Server::<PythonAnalyzer, SimplePythonParser>::new(cfg, /* Option<Sender<serde_json::value::Value>> */);
    |                                                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Also:

❯ cargo --version      
cargo 1.72.0 (103a7ff2e 2023-08-15)

and

❯ rustup --version
rustup 1.26.0 (2023-05-04)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.72.0 (5680fa18f 2023-08-23)`

bug: failed to build on macOS 13.4

Super excited about a rust-based LSP and type checker! Blazing fast, here we go!

Was unfortunately unable to build due to type errors.

macOS 13.4
M1 MBP
Rust 1.70.0

Error output
cargo install pylyzer                                         
    Updating crates.io index
  Downloaded pylyzer v0.0.31
  Downloaded 1 crate (1.2 MB) in 0.97s
  Installing pylyzer v0.0.31
    Updating crates.io index
  Downloaded fake-simd v0.1.2
  Downloaded erg_parser v0.6.14
  Downloaded lsp-types v0.93.2
  Downloaded num-bigint v0.2.6
  Downloaded ordermap v0.3.5
  Downloaded petgraph v0.4.13
  Downloaded py2erg v0.0.31
  Downloaded sha2 v0.8.2
  Downloaded string_cache v0.7.5
  Downloaded rustpython-parser v0.1.2
  Downloaded term v0.5.2
  Downloaded unicode-xid v0.1.0
  Downloaded unic-ucd-ident v0.9.0
  Downloaded unicode_names2 v0.4.0
  Downloaded fixedbitset v0.1.9
  Downloaded precomputed-hash v0.1.1
  Downloaded new_debug_unreachable v1.0.4
  Downloaded string_cache_shared v0.3.0
  Downloaded string_cache_codegen v0.4.4
  Downloaded lalrpop-util v0.17.2
  Downloaded byte-tools v0.3.1
  Downloaded block-padding v0.1.5
  Downloaded diff v0.1.13
  Downloaded dirs v1.0.5
  Downloaded docopt v1.1.1
  Downloaded els v0.1.26
  Downloaded ena v0.13.1
  Downloaded block-buffer v0.7.3
  Downloaded erg_common v0.6.14
  Downloaded ascii-canvas v2.0.0
  Downloaded itertools v0.8.2
  Downloaded generic-array v0.12.4
  Downloaded digest v0.8.1
  Downloaded opaque-debug v0.2.3
  Downloaded lalrpop v0.17.2
  Downloaded rand_hc v0.1.0
  Downloaded bitflags v1.3.2
  Downloaded aho-corasick v1.0.2
  Downloaded serde v1.0.164
  Downloaded bit-set v0.5.3
  Downloaded bit-vec v0.6.3
  Downloaded rand_chacha v0.1.1
  Downloaded rand_core v0.4.2
  Downloaded rand_jitter v0.1.4
  Downloaded rand_pcg v0.1.2
  Downloaded rand_xorshift v0.1.1
  Downloaded rand_isaac v0.1.1
  Downloaded rand_core v0.3.1
  Downloaded phf_shared v0.7.24
  Downloaded phf_generator v0.7.24
  Downloaded lazy_static v1.4.0
  Downloaded either v1.8.1
  Downloaded autocfg v0.1.8
  Downloaded atty v0.2.14
  Downloaded log v0.4.19
  Downloaded regex v1.8.4
  Downloaded serde_derive v1.0.164
  Downloaded unic-char-property v0.9.0
  Downloaded num-traits v0.2.15
  Downloaded strsim v0.10.0
  Downloaded siphasher v0.2.3
  Downloaded proc-macro2 v1.0.60
  Downloaded unic-emoji-char v0.9.0
  Downloaded rand v0.6.5
  Downloaded unicode-xid v0.2.4
  Downloaded quote v1.0.28
  Downloaded memchr v2.5.0
  Downloaded serde_json v1.0.96
  Downloaded num-integer v0.1.45
  Downloaded unic-char-range v0.9.0
  Downloaded unic-common v0.9.0
  Downloaded tinyvec v1.6.0
  Downloaded tinyvec_macros v0.1.1
  Downloaded form_urlencoded v1.2.0
  Downloaded rand_os v0.1.3
  Downloaded byteorder v1.4.3
  Downloaded unicode-bidi v0.3.13
  Downloaded url v2.4.0
  Downloaded serde_repr v0.1.12
  Downloaded percent-encoding v2.3.0
  Downloaded typenum v1.16.0
  Downloaded unicode-ident v1.0.9
  Downloaded unicode-normalization v0.1.22
  Downloaded itoa v1.0.6
  Downloaded syn v2.0.18
  Downloaded unic-ucd-version v0.9.0
  Downloaded ryu v1.0.13
  Downloaded idna v0.4.0
  Downloaded regex-syntax v0.7.2
  Downloaded erg_compiler v0.6.14
  Downloaded regex-syntax v0.6.29
  Downloaded libc v0.2.146
  Downloaded autocfg v1.1.0
  Downloaded 93 crates (5.6 MB) in 1.49s
   Compiling autocfg v1.1.0
   Compiling proc-macro2 v1.0.60
   Compiling quote v1.0.28
   Compiling unicode-ident v1.0.9
   Compiling rand_core v0.4.2
   Compiling libc v0.2.146
   Compiling serde v1.0.164
   Compiling siphasher v0.2.3
   Compiling rand_core v0.3.1
   Compiling autocfg v0.1.8
   Compiling rand_hc v0.1.0
   Compiling rand_isaac v0.1.1
   Compiling rand_xorshift v0.1.1
   Compiling typenum v1.16.0
   Compiling phf_shared v0.7.24
   Compiling rand_chacha v0.1.1
   Compiling rand_pcg v0.1.2
   Compiling rand v0.6.5
   Compiling erg_common v0.6.14
   Compiling memchr v2.5.0
   Compiling string_cache_shared v0.3.0
   Compiling rand_jitter v0.1.4
   Compiling rand_os v0.1.3
   Compiling byteorder v1.4.3
   Compiling byte-tools v0.3.1
   Compiling syn v2.0.18
   Compiling block-padding v0.1.5
   Compiling dirs v1.0.5
   Compiling regex-syntax v0.7.2
   Compiling lazy_static v1.4.0
   Compiling aho-corasick v1.0.2
   Compiling term v0.5.2
   Compiling num-traits v0.2.15
   Compiling opaque-debug v0.2.3
   Compiling new_debug_unreachable v1.0.4
   Compiling log v0.4.19
   Compiling fake-simd v0.1.2
   Compiling phf_generator v0.7.24
   Compiling generic-array v0.12.4
   Compiling string_cache_codegen v0.4.4
   Compiling precomputed-hash v0.1.1
   Compiling tinyvec_macros v0.1.1
   Compiling block-buffer v0.7.3
   Compiling digest v0.8.1
   Compiling ordermap v0.3.5
   Compiling strsim v0.10.0
   Compiling either v1.8.1
   Compiling bit-vec v0.6.3
   Compiling fixedbitset v0.1.9
   Compiling string_cache v0.7.5
   Compiling bit-set v0.5.3
   Compiling petgraph v0.4.13
   Compiling itertools v0.8.2
   Compiling sha2 v0.8.2
   Compiling tinyvec v1.6.0
   Compiling ena v0.13.1
   Compiling ascii-canvas v2.0.0
   Compiling atty v0.2.14
   Compiling regex v1.8.4
   Compiling num-integer v0.1.45
   Compiling unic-common v0.9.0
   Compiling serde_derive v1.0.164
   Compiling unicode-xid v0.1.0
   Compiling unic-char-range v0.9.0
   Compiling regex-syntax v0.6.29
   Compiling lalrpop-util v0.17.2
   Compiling diff v0.1.13
   Compiling unic-char-property v0.9.0
   Compiling unic-ucd-version v0.9.0
   Compiling unicode-normalization v0.1.22
   Compiling num-bigint v0.2.6
   Compiling unicode-xid v0.2.4
   Compiling erg_compiler v0.6.14
   Compiling percent-encoding v2.3.0
   Compiling unicode-bidi v0.3.13
   Compiling serde_json v1.0.96
   Compiling form_urlencoded v1.2.0
   Compiling idna v0.4.0
   Compiling erg_parser v0.6.14
   Compiling ryu v1.0.13
   Compiling itoa v1.0.6
   Compiling unic-ucd-ident v0.9.0
   Compiling unic-emoji-char v0.9.0
   Compiling serde_repr v0.1.12
   Compiling bitflags v1.3.2
   Compiling unicode_names2 v0.4.0
   Compiling docopt v1.1.1
   Compiling url v2.4.0
   Compiling lalrpop v0.17.2
   Compiling lsp-types v0.93.2
   Compiling rustpython-parser v0.1.2
   Compiling els v0.1.26
   Compiling py2erg v0.0.31
error[E0308]: mismatched types
    --> /Users/Leisure/.cargo/registry/src/index.crates.io-6f17d22bba15001f/py2erg-0.0.31/convert.rs:1272:18
     |
1272 |             Some(class_spec),
     |             ---- ^^^^^^^^^^ expected `TypeSpecWithOp`, found `TypeSpec`
     |             |
     |             arguments to this enum variant are incorrect
     |
help: the type constructed contains `TypeSpec` due to the type of the argument passed
    --> /Users/Leisure/.cargo/registry/src/index.crates.io-6f17d22bba15001f/py2erg-0.0.31/convert.rs:1272:13
     |
1272 |             Some(class_spec),
     |             ^^^^^----------^
     |                  |
     |                  this argument influences the type of `Some`
note: tuple variant defined here
    --> /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/option.rs:572:5

error[E0308]: mismatched types
    --> /Users/Leisure/.cargo/registry/src/index.crates.io-6f17d22bba15001f/py2erg-0.0.31/convert.rs:1296:18
     |
1296 |             Some(class_spec),
     |             ---- ^^^^^^^^^^ expected `TypeSpecWithOp`, found `TypeSpec`
     |             |
     |             arguments to this enum variant are incorrect
     |
help: the type constructed contains `TypeSpec` due to the type of the argument passed
    --> /Users/Leisure/.cargo/registry/src/index.crates.io-6f17d22bba15001f/py2erg-0.0.31/convert.rs:1296:13
     |
1296 |             Some(class_spec),
     |             ^^^^^----------^
     |                  |
     |                  this argument influences the type of `Some`
note: tuple variant defined here
    --> /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/option.rs:572:5

error[E0308]: mismatched types
    --> /Users/Leisure/.cargo/registry/src/index.crates.io-6f17d22bba15001f/py2erg-0.0.31/convert.rs:1442:17
     |
1437 |             let sig = Signature::Subr(SubrSignature::new(
     |                                       ------------------ arguments to this function are incorrect
...
1442 |                 return_t,
     |                 ^^^^^^^^ expected `Option<TypeSpecWithOp>`, found `Option<TypeSpec>`
     |
     = note: expected enum `Option<erg_compiler::erg_parser::ast::TypeSpecWithOp>`
                found enum `Option<TypeSpec>`
note: associated function defined here
    --> /Users/Leisure/.cargo/registry/src/index.crates.io-6f17d22bba15001f/erg_parser-0.6.14/ast.rs:3907:18
     |
3907 |     pub const fn new(
     |                  ^^^

For more information about this error, try `rustc --explain E0308`.
error: could not compile `py2erg` (lib) due to 3 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to compile `pylyzer v0.0.31`, intermediate artifacts can be found at `/var/folders/tx/6pp47_bj75z6xtv1jmt7rpk00000gq/T/cargo-installE807Bp`

Anything else I can do to help? :-)

[Compatibility] Helix can't connect: pylyzer closes the stream

Version: https://github.com/mtshiba/pylyzer/releases/tag/v0.0.10

https://github.com/helix-editor/helix errors out with

2023-03-10T17:37:49.871 helix_lsp [ERROR] failed to initialize language server: server closed the stream
2023-03-10T17:37:49.871 helix_lsp::transport [ERROR] err: <- StreamClosed

To reproduce, replace "pylsp" with "pylyzer" in languages.toml (root folder) and open any python file.
helix logs are in ~/.cache/helix/helix.log

As a tool for python developers: readability is debatable

On the advantages in the README readability is listed as a point, compared to pyright/pytype.

IMHO this is a so-so situation, just using the examples on the README:

  • On the one hand pylyzer does provide a print out of the code location that causes the problem instead of the very stupid column:line of pyright.
  • But on the other hand, pylyzer recapitalizes half of the problems (and python is case sensitive). My problem is that something does not implement "add", not "Add", my object "expected str, not int", not "Str" and "Int", this is confusing mental overload to double-check what was capitalized or not. And yes, methods in python should not be capitalized so many cases shold be clear... except you may be developing with PyQT or other libraries wrapping C++ and the whole capitalization is all over the place. Other tools respect the capitalization of the original code as well as python conventions.
  • Additionally, I don't know if somebody smarter than I can extract hidden meaning from AttributeError: |%3: Type, %2<: Add(%3)|(x: %2, y: %3) -> %2.Output object has no attribute x but for me most of the line is undecipherable noise except the very last part, object has no attribute x.

So, as constructive criticism: consider what a python developer needs to see and how is expecting to see it.

Package-level imports resolution

Additionally to virtualenv site-packages and 3rd-party packages, seems that last release (v0.0.27, language server) not able to resolve imports inside package:

Having simple package structure

❯ tree
.
├── example
│   ├── __init__.py
│   ├── a
│   │   ├── __init__.py
│   │   └── a.py
│   └── b
│       ├── __init__.py
│       └── b.py
└── pyproject.toml

Having class A defined in example/a/a.py attempt to import it in example/b/b.py finishes with an error:

image

pylyzer installed in Neovim/Mason
root directory is defined correctly as project root

Out-of-bounds error message not reported from inside a function

Going over what the README.md mentioned, this code snippet caused an error:

d = {"a": 1, "b": 2}
print(d["c"])
./pylyzer test.py --verbose
Start checking: test.py
Found 1 errors: test.py
Error[#0346]: File test.py, line 15, <module>

15 | print(d["c"])
   :       -

IndexError: {{"a", }: {1, }, {"b", }: {2, }} has no key {"c", }

But this snippet does not cause an error:

def main():
    d = {"a": 1, "b": 2}
    print(d["c"])


if __name__ == "__main__":
    main()
./pylyzer test.py --verbose
Start checking: test.py
All checks OK: test.py

Side note: I'm with zed.dev and we're very excited to have a better option over Pyright! We're very excited about language servers written in Rust, as we write our editor in Rust!

Not yet implemented error when using with Neovim

Thank you for this project! I was so tired of pyright taking such a long time to analyze files in my large Python projects.

However, when I try to use this with Neovim 0.9 on my Apple Silicon MacBook Pro, it quits with the following error:

[ERROR][2023-05-02 09:46:30] .../vim/lsp/rpc.lua:734	"rpc"	"pylyzer"	"stderr"	"thread 'main' panicked at 'not yet implemented', /Users/nmadnani/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_compiler-0.6.12-nightly.4/context/eval.rs:1444:53\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n"

I installed pylyzer using Mason and configured it using lspconfig.

Problem with start pylyzer on neovim

Hi. Help me undestand how to make to pylyzer work for me.
I am use two prebuilds on neovim
LunarVim
https://www.lunarvim.org/
LazyVim
https://www.lazyvim.org/configuration/general

Both of them use Mason plugins manager.
My OS is VoidLinux and MacOS

I have installed rust on my PCs.

─  rustc --version                                                                                                                     1 (0.186s)
rustc 1.69.0 (84c898d65 2023-04-16)

─  rustup --version                                                                                                                    
rustup 1.26.0 (5af9b9484 2023-04-05)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.69.0 (84c898d65 2023-04-16)

I see that is productive release of pylyzer is 0.0.22 but mason pm and cargo show 0.0.20 version

─  cargo search pylyzer                                                                                                                0 (0.154s)
pylyzer = "0.0.20"    # A static code analyzer & language server for Python

PIP show pylyzer 0.0.22

So, mason plugins install the same version 0.0.20 and els 1.23 nightly
With this version i have error from here
#19

So, wich steps i must do to make that pylyzer will work?
Thanks

Crash on parsing call statement

pylyzer 0.0.47

I used this file: https://github.com/python/cpython/blob/3.10/Lib/test/test_grammar.py

RUST_BACKTRACE=1 pylyzer grammar_py310.py

thread 'pylyzer' panicked at 'called `Option::unwrap()` on a `None` value', /Users/wookayin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/py2erg-0.0.47/convert.rs:1057:40
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: py2erg::convert::ASTConverter::convert_expr::{{closure}}
   4: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
   5: alloc::vec::in_place_collect::<impl alloc::vec::spec_from_iter::SpecFromIter<T,I> for alloc::vec::Vec<T>>::from_iter
   6: py2erg::convert::ASTConverter::convert_expr
   7: py2erg::convert::ASTConverter::convert_statement
   8: py2erg::convert::ASTConverter::convert_block
   9: py2erg::convert::ASTConverter::convert_statement
  10: py2erg::convert::ASTConverter::convert_statement
  11: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
  12: alloc::vec::in_place_collect::<impl alloc::vec::spec_from_iter::SpecFromIter<T,I> for alloc::vec::Vec<T>>::from_iter
  13: py2erg::convert::ASTConverter::convert_program
  14: pylyzer::analyze::PythonAnalyzer::analyze
  15: pylyzer::analyze::PythonAnalyzer::run
  16: pylyzer::run
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Thread panicked: Any { .. }

L1057: https://github.com/mtshiba/pylyzer/blob/main/crates/py2erg/convert.rs#L1057

Support external modules resolving

Currently, pylyzer does not know the location of locally installed 3rd party modules, so it is unable to resolve them. This is needed to fix.

[Feature Request] Local package resolve

Hi, thanks for all the great work. I'm looking forward to try this out soon.

One major feature preventing me to use it daily is the ability to resolve locally installed package in virtual environment.

I know this is already on the todo list in the readme but I just want to create a tracking issue to be notified when it is available. I hope that it is OK, but feel free to close it not.

Tags are not on the main branch

Hello,
I'm currently packaging pylyzer on the Arch User Repository.
I'm discovering that the git tags aren't on the main branch, but on the crates.io branch.
So, I have a question : for the pylyzer-git package, that should track the dev branch, should it track the mainor crates.io branch ?

Thanks for your reply !

[BUG] Compilation error on `v0.0.11`

Hi, I tried to run (cargo install pylyzer) but it failed :(

$ cargo install pylyzer
    Updating crates.io index
  Downloaded pylyzer v0.0.11
  Downloaded 1 crate (690.1 KB) in 3.41s
  Installing pylyzer v0.0.11
  Downloaded either v1.8.1
  Downloaded fake-simd v0.1.2
  Downloaded bitflags v1.3.2
  Downloaded rand_core v0.4.2
  Downloaded itoa v1.0.6
  Downloaded idna v0.3.0
  Downloaded rand_os v0.1.3
  Downloaded unicode-normalization v0.1.22
  Downloaded digest v0.8.1
  Downloaded diff v0.1.13
  Downloaded generic-array v0.12.4
  Downloaded rand_hc v0.1.0
  Downloaded rand_chacha v0.1.1
  Downloaded byte-tools v0.3.1
  Downloaded block-padding v0.1.5
  Downloaded lazy_static v1.4.0
  Downloaded aho-corasick v0.7.20
  Downloaded serde_repr v0.1.11
  Downloaded num-bigint v0.2.6
  Downloaded block-buffer v0.7.3
  Downloaded regex-syntax v0.6.28
  Downloaded ryu v1.0.13
  Downloaded form_urlencoded v1.1.0
  Downloaded unicode-xid v0.1.0
  Downloaded tinyvec v1.6.0
  Downloaded rand_core v0.3.1
  Downloaded unicode-xid v0.2.4
  Downloaded unicode-bidi v0.3.11
  Downloaded unicode-ident v1.0.8
  Downloaded num-traits v0.2.15
  Downloaded syn v1.0.109
  Downloaded strsim v0.10.0
  Downloaded rand_isaac v0.1.1
  Downloaded url v2.3.1
  Downloaded unic-ucd-ident v0.9.0
  Downloaded tinyvec_macros v0.1.1
  Downloaded num-integer v0.1.45
  Downloaded unic-char-property v0.9.0
  Downloaded rand_xorshift v0.1.1
  Downloaded quote v1.0.24
  Downloaded unic-char-range v0.9.0
  Downloaded sha2 v0.8.2
  Downloaded proc-macro2 v1.0.52
  Downloaded rand_pcg v0.1.2
  Downloaded unicode_names2 v0.4.0
  Downloaded libc v0.2.140
  Downloaded rand_jitter v0.1.4
  Downloaded itertools v0.8.2
  Downloaded siphasher v0.2.3
  Downloaded serde v1.0.155
  Downloaded new_debug_unreachable v1.0.4
  Downloaded rand v0.6.5
  Downloaded phf_generator v0.7.24
  Downloaded dirs v1.0.5
  Downloaded log v0.4.17
  Downloaded serde_derive v1.0.155
  Downloaded lsp-types v0.93.2
  Downloaded atty v0.2.14
  Downloaded serde_json v1.0.94
  Downloaded precomputed-hash v0.1.1
  Downloaded percent-encoding v2.2.0
  Downloaded typenum v1.16.0
  Downloaded regex v1.7.1
  Downloaded memchr v2.5.0
  Downloaded autocfg v1.1.0
  Downloaded docopt v1.1.1
  Downloaded opaque-debug v0.2.3
  Downloaded byteorder v1.4.3
  Downloaded bit-set v0.5.3
  Downloaded autocfg v0.1.8
  Downloaded bit-vec v0.6.3
  Downloaded ascii-canvas v2.0.0
  Downloaded fixedbitset v0.1.9
  Downloaded phf_shared v0.7.24
  Downloaded ordermap v0.3.5
  Downloaded ena v0.13.1
  Downloaded unic-emoji-char v0.9.0
  Downloaded unic-ucd-version v0.9.0
  Downloaded string_cache v0.7.5
  Downloaded py2erg v0.0.11
  Downloaded unic-common v0.9.0
  Downloaded petgraph v0.4.13
  Downloaded lalrpop-util v0.17.2
  Downloaded string_cache_codegen v0.4.4
  Downloaded string_cache_shared v0.3.0
  Downloaded rustpython-parser v0.1.2
  Downloaded els v0.1.20-nightly.0
  Downloaded erg_common v0.6.8-nightly.0
  Downloaded term v0.5.2
  Downloaded erg_parser v0.6.8-nightly.0
  Downloaded erg_compiler v0.6.8-nightly.0
  Downloaded lalrpop v0.17.2
  Downloaded 92 crates (5.1 MB) in 2.97s
   Compiling autocfg v1.1.0
   Compiling libc v0.2.140
   Compiling proc-macro2 v1.0.52
   Compiling unicode-ident v1.0.8
   Compiling quote v1.0.24
   Compiling rand_core v0.4.2
   Compiling syn v1.0.109
   Compiling serde v1.0.155
   Compiling serde_derive v1.0.155
   Compiling typenum v1.16.0
   Compiling siphasher v0.2.3
   Compiling memchr v2.5.0
   Compiling log v0.4.17
   Compiling autocfg v0.1.8
   Compiling rand_core v0.3.1
   Compiling rand_jitter v0.1.4
   Compiling rand_isaac v0.1.1
   Compiling rand_pcg v0.1.2
   Compiling rand_chacha v0.1.1
   Compiling rand v0.6.5
   Compiling rand_hc v0.1.0
   Compiling rand_xorshift v0.1.1
   Compiling phf_shared v0.7.24
   Compiling erg_common v0.6.8-nightly.0
   Compiling byteorder v1.4.3
   Compiling string_cache_shared v0.3.0
   Compiling byte-tools v0.3.1
   Compiling block-padding v0.1.5
   Compiling lazy_static v1.4.0
   Compiling regex-syntax v0.6.28
   Compiling cfg-if v1.0.0
   Compiling num-traits v0.2.15
   Compiling opaque-debug v0.2.3
   Compiling precomputed-hash v0.1.1
   Compiling strsim v0.10.0
   Compiling fake-simd v0.1.2
   Compiling aho-corasick v0.7.20
   Compiling new_debug_unreachable v1.0.4
   Compiling either v1.8.1
   Compiling fixedbitset v0.1.9
   Compiling tinyvec_macros v0.1.1
   Compiling rand_os v0.1.3
   Compiling dirs v1.0.5
   Compiling ordermap v0.3.5
   Compiling bit-vec v0.6.3
   Compiling itertools v0.8.2
   Compiling generic-array v0.12.4
   Compiling term v0.5.2
   Compiling tinyvec v1.6.0
   Compiling bit-set v0.5.3
   Compiling block-buffer v0.7.3
   Compiling digest v0.8.1
   Compiling petgraph v0.4.13
   Compiling ascii-canvas v2.0.0
   Compiling sha2 v0.8.2
   Compiling atty v0.2.14
   Compiling ena v0.13.1
   Compiling num-integer v0.1.45
   Compiling unic-common v0.9.0
   Compiling unic-char-range v0.9.0
   Compiling phf_generator v0.7.24
   Compiling unicode-xid v0.1.0
   Compiling diff v0.1.13
   Compiling lalrpop-util v0.17.2
   Compiling unic-char-property v0.9.0
   Compiling string_cache_codegen v0.4.4
   Compiling unicode-normalization v0.1.22
   Compiling unic-ucd-version v0.9.0
   Compiling num-bigint v0.2.6
   Compiling unicode-xid v0.2.4
   Compiling regex v1.7.1
   Compiling serde_json v1.0.94
   Compiling unicode-bidi v0.3.11
   Compiling percent-encoding v2.2.0
   Compiling string_cache v0.7.5
   Compiling idna v0.3.0
   Compiling form_urlencoded v1.1.0
   Compiling itoa v1.0.6
   Compiling ryu v1.0.13
   Compiling erg_compiler v0.6.8-nightly.0
   Compiling unic-emoji-char v0.9.0
   Compiling unic-ucd-ident v0.9.0
   Compiling erg_parser v0.6.8-nightly.0
   Compiling bitflags v1.3.2
   Compiling unicode_names2 v0.4.0
   Compiling serde_repr v0.1.11
   Compiling docopt v1.1.1
   Compiling url v2.3.1
   Compiling lalrpop v0.17.2
   Compiling lsp-types v0.93.2
   Compiling rustpython-parser v0.1.2
   Compiling els v0.1.20-nightly.0
error: `char::methods::<impl char>::from_u32` is not yet stable as a const fn
   --> /home/hoppingturtles/.cargo/registry/src/github.com-1ecc6299db9ec823/els-0.1.20-nightly.0/completion.rs:96:38
    |
96  |       pub const STD_ITEM: char = match char::from_u32(
    |  ______________________________________^
97  | |         CompletionOrder::Normal as u32
98  | |             + CompletionOrder::Builtin as u32
99  | |             + CompletionOrder::OtherNamespace as u32,
100 | |     ) {
    | |_____^

error: could not compile `els` due to previous error
warning: build failed, waiting for other jobs to finish...
error: failed to compile `pylyzer v0.0.11`, intermediate artifacts can be found at `/tmp/cargo-installo7hGOi`

Also, I tried installing the VSCode extension, but I don't see the pylyzer language server in my settings, am I doing something wrong?
image

Edit: VSCode gave me this error:

[Error - 10:19:15 PM] pylyzer client: couldn't create connection to server.
Launching server using command pylyzer failed. Error: spawn pylyzer ENOENT

OS: Windows 11, but ran this on WSL2 (Ubuntu, kernel version: 5.15.90.1-microsoft-standard-WSL2)

[Feature] failure to source imported modules from pyenv virtualenv site-packages folder

Problem statement

  • Pylyzer was not capable to find imported modules from virtualenv site-packages folder with pyenv.
  • on below example I import module openai, but it will work with any python package loaded with pip
  • virtualenv is an essential feature for serious pythonistas, without it pylyzer is simply not usable :'(
  • Note for @mtshiba : best of luck, besides usability, performance are outstanding and overall project is very promising

Feature Request

I would like to be able to:

  • pick by default the virtualenv based on pyenv environment variables
  • similar to pyright, specify the --venv-path /Users/aa/.pyenv/versions where are located all my virtualenvs
  • similar to pyright, specify a venv subdirectory name (subdirectory in --venv-path)
  • ovverride all the above if a pyproject.toml specify a different virtualenv name or path

How to reproduce

The issue below has been reproduced with pylyzer installed with either cargo or mason with lspconfig

On a macbook, I have:

  1. Installed pyenv with virtualenv via homebrew, setup zsh,
  2. create and activate a new virtualenv, executed pyenv local, pyenv shell and pyenv global
  3. use pip to install any python module (e.g openai)
  4. executed pylyzer on the same virtualenv but it fails to pick imported module (e.g openai)
cd workspace
pyenv virtualenv 3.11.3  my-fresh-new-env
pyenv activate my-fresh-new-env
(my-fresh-new-env) aa@macbook workspace % pip install openai
(my-fresh-new-env) aa@macbook workspace % /Users/aa/.local/share/nvim/mason/bin/pylyzer test.py
Start checking: test.py
Found 3 errors: test.py
Error[#1896]: File test.py, line 2, <module>

2 | import openai
  : --------

ImportError: module openai not found

Error[#0624]: File test.py, line 5, <module>

5 | openai.api_key = os.getenv("OPENAI_API_KEY")
  :        -------

AttributeError: PyModule("openai") object has no attribute api_key

Error[#0624]: File test.py, line 6, <module>.response

6 | response = openai.Model.list()
  :                   -----

AttributeError: PyModule("openai") object has no attribute Model

Content of test.py:

import os
import openai

openai.api_key = os.getenv("OPENAI_API_KEY")
response = openai.Model.list()
print(response)

I have tried again after forcing the virtualenv, but same result

pyenv local my-fresh-new-env
pyenv shell my-fresh-new-env
pyenv global my-fresh-new-env

Check our environment variable

Our python, pyenv, virtualenv seems correct as shown below

env | grep -i pyenv 
PATH=/Users/aa/.cargo/bin:/usr/local/Cellar/pyenv-virtualenv/1.2.1/shims:/Users/aa/.pyenv/shims:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin
PYENV_SHELL=zsh
PYENV_VIRTUALENV_INIT=1
PYENV_VERSION=my-fresh-new-env
PYENV_ACTIVATE_SHELL=1
PYENV_VIRTUAL_ENV=/Users/aa/.pyenv/versions/3.11.3/envs/my-fresh-new-env
VIRTUAL_ENV=/Users/aa/.pyenv/versions/3.11.3/envs/my-fresh-new-env

the correct python path is picked from our virtualenv:

whereis python
python: /Users/aa/.pyenv/shims/python

Same issue with mason and lspconfig

pylyzer fails short at finding modules in the virtualenv site-packages folder

image

pylyzer is correclty configured and installed with lspconfig and mason as shown by nvim command :LspInfo

 Client: pylyzer (id: 1, bufnr: [1])
 	filetypes:       python
 	autostart:       true
 	root directory:  /Users/aa/workspace
 	cmd:             /Users/aa/.local/share/nvim/mason/bin/pylyzer --server

 Configured servers list: gopls, pylyzer

Example of the python imports can be overriden with pyright

cat pyproject.toml
[tool.pyright]
venvPath = "/Users/aa/.pyenv/versions"
venv = "my-fresh-new-env"

pip install pylyzer to install erg as well

Hi,

First of all, cheers for this awesome package.

Would it be possible to add the Erg installation to setup.py, or by some other method, so that erg is installed when one runs
pip install pylyzer?

(ie the same way pandas installs numpy etc. for you when you run pip install pandas)

Thanks,
Eli

[Bug] Server fails with "No such file or directory" on startup

Hi, thank you for this nice project. I'd love to ditch pylance, as it's a memory and cpu hog. However starting the server fails for me on Ubuntu 20.10.

Edit: I just noticed you mention this in the readme, however this should not happen either way. At least not this cryptically

$ RUST_BACKTRACE=full pylyzer --server
thread 'main' panicked at 'ERG_PATH not found: Os { code: 2, kind: NotFound, message: "No such file or directory" }', /home/shiba/.cargo/registry/src/github.com-1ecc6299db9ec823/erg_common-0.6.10-nightly.0/env.rs:10:10
stack backtrace:
   0:     0x55ca2e393a0a - std::backtrace_rs::backtrace::libunwind::trace::h595f06c70adcc478
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x55ca2e393a0a - std::backtrace_rs::backtrace::trace_unsynchronized::h177a0149c76cdde9
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x55ca2e393a0a - std::sys_common::backtrace::_print_fmt::hc0701fd2c3530c58
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x55ca2e393a0a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd4cd115d8750fd6c
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x55ca2e3b7e7e - core::fmt::write::h93e2f5923c7eca08
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/fmt/mod.rs:1213:17
   5:     0x55ca2e390165 - std::io::Write::write_fmt::h8162dbb45f0b9e62
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/io/mod.rs:1682:15
   6:     0x55ca2e3937d5 - std::sys_common::backtrace::_print::h1835ef8a8f9066da
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x55ca2e3937d5 - std::sys_common::backtrace::print::hcb5e6388b9235f41
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x55ca2e394fbf - std::panicking::default_hook::{{closure}}::h9c084969ccf9a722
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:267:22
   9:     0x55ca2e394cfb - std::panicking::default_hook::h68fa2ba3c3c6c12f
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:286:9
  10:     0x55ca2e3956c9 - std::panicking::rust_panic_with_hook::h8d5c434518ef298c
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:688:13
  11:     0x55ca2e395469 - std::panicking::begin_panic_handler::{{closure}}::hf33414f5dabf6faf
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:579:13
  12:     0x55ca2e393ebc - std::sys_common::backtrace::__rust_end_short_backtrace::hc50389427413bb75
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys_common/backtrace.rs:137:18
  13:     0x55ca2e395172 - rust_begin_unwind
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:575:5
  14:     0x55ca2d6510e3 - core::panicking::panic_fmt::h2de7a7938f816de8
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/panicking.rs:64:14
  15:     0x55ca2d651593 - core::result::unwrap_failed::hdc73d4affce1d414
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/result.rs:1790:5
  16:     0x55ca2e36be90 - erg_common::env::_erg_path::h7c41c06ca9e5d471
  17:     0x55ca2e3706b2 - std::thread::local::fast::Key<T>::try_initialize::h4299a168d7d6c295
  18:     0x55ca2e36c56b - erg_common::env::erg_path::hfa6affc8237ac118
  19:     0x55ca2d6f0fdb - els::server::Server<Checker>::new::hbc66c4a0ce7a9149
  20:     0x55ca2d6bb6ff - pylyzer::run::hee0ea689a38a6591
  21:     0x55ca2d6bca23 - std::sys_common::backtrace::__rust_begin_short_backtrace::hf6761b5953500095
  22:     0x55ca2d77f709 - std::rt::lang_start::{{closure}}::h4fb14a749e265ed4
  23:     0x55ca2e38b3ac - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h699977d052768608
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/ops/function.rs:287:13
  24:     0x55ca2e38b3ac - std::panicking::try::do_call::h4e121e623c70f903
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:483:40
  25:     0x55ca2e38b3ac - std::panicking::try::hf9d919e062bc178a
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:447:19
  26:     0x55ca2e38b3ac - std::panic::catch_unwind::h7a7b12272684cb97
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panic.rs:140:14
  27:     0x55ca2e38b3ac - std::rt::lang_start_internal::{{closure}}::hd96b0eb4844b8762
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/rt.rs:148:48
  28:     0x55ca2e38b3ac - std::panicking::try::do_call::h1af1f88f4f92a22c
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:483:40
  29:     0x55ca2e38b3ac - std::panicking::try::hf20d7abea7f0f097
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:447:19
  30:     0x55ca2e38b3ac - std::panic::catch_unwind::hb0e084c3a9c042e4
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panic.rs:140:14
  31:     0x55ca2e38b3ac - std::rt::lang_start_internal::hca9d5c7277f5b67c
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/rt.rs:148:20
  32:     0x55ca2d6bb865 - main
  33:     0x7f0a6b82c083 - __libc_start_main
                               at /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
  34:     0x55ca2d65177e - _start
  35:                0x0 - <unknown>

Installed using pip

$ python3 -m pip install pylyzer
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
Collecting pylyzer
  Downloading pylyzer-0.0.17-py3-none-manylinux_2_31_x86_64.whl (7.0 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.0/7.0 MB 1.8 MB/s eta 0:00:00
Installing collected packages: pylyzer
Successfully installed pylyzer-0.0.17

System:

Linux <hostname> 5.8.0-63-generic #71~20.04.1-Ubuntu SMP Thu Jul 15 17:46:08 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

inlay hint causes panic in neovim-nightly

[ERROR][2023-05-28 19:49:18] .../vim/lsp/rpc.lua:734 "rpc" "/home/henryw/.local/share/nvim/mason/bin/pylyzer" "stderr" "thread 'main' panicked at 'called Option::unwrap() on a None value', /home/henryw/.cargo/registry/src/github.com-1ecc6299db9ec823/els-0.1.26-nightly.0/inlay_hint.rs:213:36\nnote: run with RUST_BACKTRACE=1 environment variable to display a backtrace\n"

replicated with this neovim config:
#40

Unreasonable errors on built-in type constructor such as int()

I found the unreasonable errors below.
It seems unresolved issues, so I report the testcase and the result. I hope this helps.

Testcases

I created 8 testcases related to built-in type constructor. These are all valid on Python 3.10.6.

def print_repr(x):
    print(repr(x))

print_repr(int("0x16", base=16))
print_repr(float('1e-003'))
print_repr(str(100))
print_repr(complex(1, 2))
print_repr(list(range(10)))
print_repr(tuple([1, 2, 3]))
print_repr(set([1, 2, 2]))
print_repr(dict([("a", 1), ("b", 2)]))
$ python3 --version
Python 3.10.6

$ python3 testcase.py 
22
0.001
'100'
(1+2j)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
(1, 2, 3)
{1, 2}
{'a': 1, 'b': 2}

Pylyzer result

Pylyzer reports 9 errors:

  • 4 "expected Callable but found ClassType"
  • 3 "Generic* is not defined"
  • 1 "complex is not defined"
  • 1 error related to List[Tuple[str, int]]
$ pylyzer --version
pylyzer 0.0.13

$ pylyzer testcase.py 
Start checking: testcase.py
Found 9 errors: testcase.py
Error[#1075]: File testcase.py, line 4, <module>

4 | print_repr(int("0x16", base=16))
  :            ---
  :              |- expected: Callable
  :              |- but found: ClassType
  :              `- If you want to generate an instance, use .Int.new

TypeError: the type of .Int(qual_name: Int)(: {Int, }) is mismatched

Error[#1075]: File testcase.py, line 5, <module>

5 | print_repr(float('1e-003'))
  :            -----
  :                |- expected: Callable
  :                |- but found: ClassType
  :                `- If you want to generate an instance, use .Float.new

TypeError: the type of .Float(qual_name: Float)(: {Float, }) is mismatched

Error[#1075]: File testcase.py, line 6, <module>

6 | print_repr(str(100))
  :            ---
  :              |- expected: Callable
  :              |- but found: ClassType
  :              `- If you want to generate an instance, use .Str.new

TypeError: the type of .Str(qual_name: Str)(: {Str, }) is mismatched

Error[#0710]: File testcase.py, line 7, <module>

7 | print_repr(complex(1, 2))
  :            -------
  :                  `- exists a similar name public variable: compile

NameError: complex is not defined

Error[#0710]: File testcase.py, line 8, <module>

8 | print_repr(list(range(10)))
  :            ------------

NameError: GenericArray is not defined

Error[#0710]: File testcase.py, line 9, <module>

9 | print_repr(tuple([1, 2, 3]))
  :            ------------
  :                       `- exists a similar name private variable: GenericTuple

NameError: GenericTuple is not defined

Error[#0710]: File testcase.py, line 10, <module>

10 | print_repr(set([1, 2, 2]))
   :            ----------

NameError: GenericSet is not defined

Error[#0230]: File testcase.py, line 11, <module>

11 | print_repr(dict([("a", 1), ("b", 2)]))
   :                             ------
   :                                  `- please specify the type explicitly, e.g. [..., ("b", 2): Tuple([{"a", }, {1, }]) or Tuple([{"b", }, {2, }])]

SyntaxError: all elements of an array must be of the same type

Error[#1075]: File testcase.py, line 11, <module>

11 | print_repr(dict([("a", 1), ("b", 2)]))
   :            -----------
   :                      |- expected: Callable
   :                      |- but found: ClassType
   :                      `- If you want to generate an instance, use .GenericDict.new

TypeError: the type of .GenericDict(qual_name: GenericDict)(: {GenericDict, }) is mismatched

Other type checkers result

All other type checkers (Pyright, Pytype, Pyre) didn't report any errors.

$ pyright testcase.py 
No configuration file found.
No pyproject.toml file found.
stubPath /home/user/work/typechecker/typings is not a valid directory.
Assuming Python platform Linux
Searching for source files
Found 1 source file
pyright 1.1.299
0 errors, 0 warnings, 0 informations 
Completed in 0.775sec

$ pytype testcase.py 
Computing dependencies
Analyzing 1 sources with 0 local dependencies
ninja: Entering directory `.pytype'
ninja: no work to do.
Leaving directory '.pytype'
Success: no errors found

$ pyre
ƛ No watchman binary found. 
To enable pyre incremental, you can install watchman: https://facebook.github.io/watchman/docs/install
ƛ Defaulting to non-incremental check.
ƛ No type errors found

[Error] Server failed with "No such file or directory"

Hi, I'm currently using pylyzer installed with cargo integrated with neovim's lsp.
The language server return me this error

[ERROR][2023-04-23 15:23:48] .../vim/lsp/rpc.lua:734	"rpc"	"pylyzer"	"stderr"	"thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: \"No such file or directory\" }', /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/els-0.1.23-nightly.2/file_cache.rs:170:10\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n"

Could you please help me with this ?

Regardless,
BlueD

Better error messages for unsupported features

Hi! pylyzer sounds like a very interesting project. However, when I tried it out on a very small program, I got a number of false positives (for the stdlib), and slow performance (for 3rd party libs).

To make the experience better for first-time users, how about exiting early from unimplemented checks, with a debug warning that that feature is not ready?

For example:

  • checking whole directories
  • checking pip-installed libraries
  • checking certain parts of the stdlib

Crash on help fuction

pylyzer 0.0.25
This is very strange. For show documentation we are use Shift + K in vim/nvim
And this is work now when i try to use it for range() and some other operatos.
But! If i try show help for print() fuction pylyzer is crashed

[ERROR][2023-05-04 10:56:19] .../vim/lsp/rpc.lua:734	"rpc"	"pylyzer"	"stderr"	"thread 'main' panicked at 'called 
`Result::unwrap()` on an `Err` value: RelativeUrlWithoutBase', 
/home/kobzar/.cargo/registry/src/github.com-1ecc6299db9ec823/els-0.1.24-nightly.6/hover.rs:183:77\n
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.