Giter VIP home page Giter VIP logo

linter-mypy's People

Contributors

askaholic avatar elarivie avatar rostislav-simonik 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

Watchers

 avatar  avatar  avatar  avatar

linter-mypy's Issues

Errors are shown on incorrect files

This is similar to #20, but different.

After linting, there will be some errors/warnings from an imported file shown on the original file. I believe that turning off the follow imports setting should remove these messages, but it doesn't.
Linting the original file then results in duplicate warnings/errors.

Additionally, the messages are shown when linting another file that is not even in the same project (so there is definitely no import link).
Once the messages are shown, the only way to remove them is by reloading the editor/restarting Atom.

Unable to find installed modules

Hi, thanks for the great package.
I seem to have an unexpected behaviour : linter-mypy does not seem to find any installed package, even through I gave the right executable (referring to a conda environment having all the installed packages).

Do you have any ideas about where I could have messed up?

Thanks a lot,
Diviyan

Doesn't find imports >= 5 levels deep

linter-mypy v2.5.2, Atom 1.23.3, Python 3.5.2. In a file OtherClassName.py:

from A.B.C.D.E.className import ClassName

"Cannot find module" warning is issued. Moving ClassName to parent folder, adjusting import to:

from A.B.C.D.className import ClassName

No problem finding module.

Adding $PROJECT_PATH/A/B/C/D/E or dot to MyPy path does not help.

Add option to only check repos where mypy.ini is present

I am playing around with MyPy with one of my Python packages, and so far linter-mypy has been working great!

However, all my other repositories do not have typehints and in fact cause MyPy to crash due to python/mypy#4111. Is there some way to disable linter-mypy for all repositories that do not have a mypy.ini file in the repository root (or through another way of detecting if a repo is using mypy?)

Thanks!

linter-mypy generating many duplicate errors

For some reason many of my mypy warnings show up multiple times. Any idea why this would be happening? I am using mypy in conjunction with the linter-flake8 package.

Imgur

Atom: 1.33.1
OS: Ubuntu 18
Python: 3.6
Pip:

mypy==0.701
mypy-extensions==0.4.1

Use $PROJECT_NAME variable in Executable Path option

I think the option to use a $PROJECT_NAME variable in the Executable Path option will be very useful to have a single configuration that can work with multiple virtual environments (for example those created with the virtualenvwrapper tool that are installed in the ~/.virtualenvs directory and that have by convention the same name of the project that uses it)

This would be similar to the Python Executable Paths of package autocomplete-python

/home/user/.virtualenvs/$PROJECT_NAME/bin/python

Thank you!

Object.dirname is deprecated.

I have recently gotten the following error after updating Atom.
Relevant information:

  • Atom: 1.23.3
  • OS: macOS 10.13.2

Argument to path.dirname must be a string

Object.dirname (/Applications/Atom.app/Contents/Resources/app/src/electron-shims.js:9:10)
Object.lintPath (/Users/calgarymichael/.atom/packages/linter-mypy/lib/init.coffee:531:23)
Object.lint (/Users/calgarymichael/.atom/packages/linter-mypy/lib/init.coffee:846:28)
a.factory (/Users/calgarymichael/.atom/packages/atom-ide-ui/modules/atom-ide-ui/pkg/atom-ide-diagnostics/lib/services/LinterAdapter.js:252:42)
a._callFactory (/Users/calgarymichael/.atom/packages/atom-ide-ui/node_modules/rxjs/bundles/Rx.min.js:107:23)
a.tryDefer (/Users/calgarymichael/.atom/packages/atom-ide-ui/node_modules/rxjs/bundles/Rx.min.js:106:442)

Option to start the mypy process from the (Atom) project directory?

I'm using type stubs in a project mine, and I put them under the $PROJECT_PATH/stubs/ directory. In my mypy.ini, I set mypy_path to stubs/ (it is a relative path on purpose). linter-mypy does not seem to be able to find my stubs, and behaves as if they are not there. I believe this is because linter-mypy runs mypy from the file system root, leading mypy to look for a /stubs/ directory which I don't have. I'm currently working around this issue by using my fork of this package that runs mypy in $PROJECT_PATH.

According to my understanding of issue #4, linter-mypy runs mypy from the file system root to avoid work around a mypy limitation with finding the top-level package in a project. I guess this behavior shouldn't change for most users in order to avoid that mypy limitation. Maybe there should be an option to change the working directory for the mypy process?

(semi-) colon separated Python Executable Path?

Linter-mypy works great for my work, but I have a small issue.

The Python Executable Path setting does not allow multiple paths.
I'd like to set "Use project-specific python if available, otherwise fallback to default python", but current linter-mypy does not seem to allow this.

Add option to set 'mypy.ini' file

First of all, thanks a lot for making this atom package! For sure it will help the Python community in the use of static typing!

I think a good addition to the linter would be to have the option to specify a per project mypy.ini file (using a $PROJECT placeholder variable). This way, users will have the control over wich options they would like to activate in a case by case basis.

For example, right now I would like to disable some Warnings regarding not found imports such as:

Cannot find module named 'aiohttp' at line 2 col 1
Cannot find module named 'aiopg' at line 3 col 1

This would be very easy if I could reference a mypy.ini file with the option:

--ignore-missing-imports

As suggested by the mypy executable itself:

aioxample@aioxample:~$ /opt/aioxample/env/bin/mypy /opt/aioxample/aioxample/polls/aiohttpdemo_polls/main.py
/opt/aioxample/aioxample/polls/aiohttpdemo_polls/main.py:3: error: Cannot find module named 'aiohttp'
/opt/aioxample/aioxample/polls/aiohttpdemo_polls/main.py:3: note: (Perhaps setting MYPYPATH or using the "--ignore-missing-imports" flag would help)

The option could be, for example:

$PROJECT/mypy.ini

For using a mypy.ini file located in the root of the repository. This path can be given to mypy executable through the --config-file option (http://mypy.readthedocs.io/en/latest/config_file.html).

Thanks a lot!

Are mypy plugins supported ?

I recently started using pydantic and wanted the extra features brought by the mypy plugin.

Here is what my setup.cfg looks like

[mypy]
python_version = 3.8
files=**/*.py
plugins = pydantic.mypy

[pydantic-mypy]
init_typed = True

In the file foo.py I have the following code:

from pydantic import BaseModel

class Foo(BaseModel):
    bar: str

Foo(bar=1)
a: str = 1

When running mypy in the command line I get the following errors (which are expected):

foo.py:6: error: Argument "bar" to "Foo" has incompatible type "int"; expected "str"
foo.py:7: error: Incompatible types in assignment (expression has type "int", variable has type "str")

However, in Atom, I only get the second error (which indicates the file in indeed watched by linter-mypy), but not the first one (provided by the pydantic-mypy plugin).

Do you have any ideas on how to debug this ?

Thank you !

Unable to find mypy, despite correct $PATH and settings

Hello,

I'm trying to use linter-mypy with Python 3 project (python installed with pyenv). When I run the linter, I get:

image

Even though I have mypy installed, and the settings for linter-mypy are correct, as far as I can tell.

$ /Users/npresta/.pyenv/shims/python -m pip install mypy
Requirement already satisfied: mypy in /Users/npresta/.pyenv/versions/3.6.2/lib/python3.6/site-packages
Requirement already satisfied: typed-ast<1.1.0,>=1.0.4 in /Users/npresta/.pyenv/versions/3.6.2/lib/python3.6/site-packages (from mypy)

Similarly, my settings are configured as such:

image

When I open up the console in Atom, I see:

> process.env['PATH']
> "/Users/npresta/.pyenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

Any ideas? I'm using Atom Beta 1.20.0-beta4

Package is showing internal mypy errors although turned off

I have the linter package running on file saves, and everytime a red pop up tells me there was an internal error:
image

The line number however points to a valid lint regarding type checks, and if I fix it, and save the file again, I get again an internal error with the next first lint in that file as line number.

So this is weird for two reasons:

  1. Why is a linter showing an internal error when it actually did the job and found the lint?
  2. Why is this pop-up showing, when I actually disabled the specific option for this in the atom package? (see following snapshot)
    image

UnicodeEncodeError

I was running a simple case:

a: int = "string"

mypy works well in the terminal environment. However, when I use linter-mypy, there will encounter an error as follows,

Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/main.py", line 11, in main(None) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/main.py", line 91, in main res = type_check_only(sources, bin_dir, options, flush_errors, fscache) # noqa File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/main.py", line 148, in type_check_only fscache=fscache) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/build.py", line 185, in build flush_errors, fscache) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/build.py", line 285, in _build graph = dispatch(sources, manager) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/build.py", line 2398, in dispatch process_graph(graph, manager) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/build.py", line 2691, in process_graph process_stale_scc(graph, scc, manager) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/build.py", line 2823, in process_stale_scc manager.flush_errors(manager.errors.file_messages(graph[id].xpath), False) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mypy/main.py", line 81, in flush_errors f.write(msg + '\n') UnicodeEncodeError: 'ascii' codec can't encode characters in position 38-39: ordinal not in range(128)

I want to know what had happened, and how to fix it.

Does not seem to work with pipenv

Pipenv creates virtual environments with a directory name that cannot be derived from $PROJECT_PATH or $PROJECT_NAME. Their way to run mypy, is pipenv run mypy .... or pipenv run python -m mypy in the project root.

I can currently only set an executable path for python in the settings of linter-mypy. I think this issue would therefore be resolved if I could provide an executable path plus arguments (eg. $PROJECT_PATH/pipenv run python).

Does not recognise typed_ast package

When I lint, the following notification is shown:

The typed_ast package is not installed. You can install it with python3 -m pip install typed-ast.

I understand this may be an issue with mypy itself (I've found a related issue), however running python -m mypy doesn't have this error.

pip freeze results (virtual environment):

appdirs==1.4.3
astroid==2.3.3
attrs==19.3.0
black==19.10b0
Click==7.0
isort==4.3.21
lazy-object-proxy==1.4.3
mccabe==0.6.1
mypy==0.750
mypy-extensions==0.4.3
pathspec==0.6.0
pkg-resources==0.0.0
pycodestyle==2.5.0
pydocstyle==4.0.1
pyflakes==2.1.1
pylama==7.7.1
pylama-pylint==3.1.1
pylint==2.4.4
regex==2019.11.1
six==1.13.0
snowballstemmer==2.0.0
toml==0.10.0
typed-ast==1.4.0
typing-extensions==3.7.4.1
wrapt==1.11.2

linter-mypy version 2.6.8 running on Ubuntu with Atom 1.41.0 x64.

It also took me a while to identify the error as being from this package.

Can't detect mypy anymore

I use pyenv, and have mypy installed in an environment I use for python-related plugins: atom_env_3.6.7. I set the path of mypy to reflect the correct python installation.

The error message says

The python package mypy does not seem to be installed. Install it with:

/my/path/to/home/.pyenv/versions/3.6.7/envs/atom_env_3.6.7/bin/python -m pip install mypy

But if I run

/my/path/to/home/.pyenv/versions/3.6.7/envs/atom_env_3.6.7/bin/python -m pip list

I get

Package                Version
---------------------- -------
autopep8               1.4.3
...
mypy                   0.700
...

And running the suggested install command does nothing because it's already installed

This started happening recently, so in the last one or two updates

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.