Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new configuration option 'config_files' #23

Closed
wants to merge 127 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
74aa977
Shifted defaults
Richardk2n Apr 25, 2020
b910675
Merge remote-tracking branch 'upstream/master'
Richardk2n Apr 25, 2020
014c32a
Find config file and better live mode
Richardk2n Apr 25, 2020
44c34f5
Changed setup and versioning
Richardk2n Jul 8, 2020
169076e
Update LICENSE
Richardk2n Jul 8, 2020
4169d69
Net necessary anymore
Richardk2n Jul 8, 2020
3f4ca48
Create python-test.yml
Richardk2n Jul 8, 2020
f526a6d
Update requirements.txt
Richardk2n Jul 8, 2020
1f44f19
Merge branch 'master' of https://github.com/Richardk2n/pyls-mypy
Richardk2n Jul 8, 2020
ce04e49
spdyder compatibility
Richardk2n Jul 8, 2020
3a275d2
formatting experiment
Richardk2n Jul 8, 2020
ba9e42b
unnecessary
Richardk2n Jul 8, 2020
ab97e0d
Update requirements.txt
Richardk2n Jul 8, 2020
236f97c
Create python-package.yml
Richardk2n Jul 8, 2020
ee5ae18
Delete python-test.yml
Richardk2n Jul 8, 2020
b4654d4
Create python-publish.yml
Richardk2n Jul 8, 2020
22aa9c2
update
Richardk2n Jul 8, 2020
a6c7c66
Merge branch 'master' of https://github.com/Richardk2n/pyls-mypy
Richardk2n Jul 8, 2020
4a34b1d
typo
Richardk2n Jul 8, 2020
a13577d
typo
Richardk2n Jul 8, 2020
a8beefa
Failed to update variable
Richardk2n Jul 8, 2020
0d3f8d8
Typing
Richardk2n Jul 10, 2020
753bc77
formatting
Richardk2n Jul 10, 2020
b5deee2
new version requirement
Richardk2n Jul 10, 2020
b9fdb51
Update python-package.yml
Richardk2n Jul 10, 2020
bf12dc9
typo
Richardk2n Jul 10, 2020
a037167
version bump
Richardk2n Jul 10, 2020
7c67590
update name. Finished for now
Richardk2n Jul 10, 2020
afd2135
update pyls
Richardk2n Jul 12, 2020
088b87a
update requirements
Richardk2n Jul 12, 2020
bbfae72
Update python-package.yml
Richardk2n Jul 12, 2020
a2db211
Update _version.py
Richardk2n Jul 12, 2020
6ed04c1
make configs work on linux
Richardk2n Oct 27, 2020
1489e85
Depend on python-lsp-server
haplo May 13, 2021
80ac5fa
Undo black formatting from commit 1489e85d4afa6d34a12
haplo May 18, 2021
4399194
Revert extra requirements from commit 1489e85d4afa6d34a
haplo May 18, 2021
817c4ef
Revert indent on README
haplo May 18, 2021
06cb3c9
Fix indent in README
haplo May 18, 2021
4b968d3
Merge pull request #2 from haplo/python-lsp-server-mypy-ls
Richardk2n May 18, 2021
f3be9a7
Fixing link formatting
Richardk2n May 18, 2021
382f6af
test 3.9 as well
Richardk2n May 18, 2021
4dd9c7e
version bump
Richardk2n May 18, 2021
906a3dd
make pipy accept formatting
Richardk2n May 18, 2021
ca189e0
Format codebase with black
haplo May 18, 2021
333125b
Merge pull request #4 from haplo/black
Richardk2n May 19, 2021
91e6ade
assure the upload will work
Richardk2n May 19, 2021
97b5b62
Add dmypy support via mypy.api.run_dmypy
asford May 19, 2021
4d7d342
Fixup README typos from review
asford May 19, 2021
6b5b5fb
Merge pull request #1 from asford/master
Richardk2n May 20, 2021
cbc2375
Check dmypy status and kill hung daemons before run
asford Jun 13, 2021
ac99feb
Merge pull request #10 from asford/dmypy_restart
Richardk2n Jun 21, 2021
1b87138
add more checks
Richardk2n Jun 21, 2021
6c44c3b
fix readme
Richardk2n Jun 21, 2021
302df62
Merge pull request #5 from Richardk2n/enforece-uploadability
Richardk2n Jun 21, 2021
ace7493
typo
Richardk2n Jun 21, 2021
0b80495
version bump
Richardk2n Jun 21, 2021
d765a5f
rename
Richardk2n Jun 21, 2021
675afa7
typo
Richardk2n Jun 21, 2021
0456ad3
Update test_plugin.py
Richardk2n Jun 21, 2021
66d9b90
Fix wrong configuration being used with multiple workspace folders
rchl Jul 1, 2021
0f6c6d7
run black
rchl Jul 3, 2021
7d9714e
Merge pull request #13 from rchl/fix/workspace-configs
Richardk2n Jul 3, 2021
46bc4f7
Merge branch 'master' into rename
Richardk2n Jul 3, 2021
2b46fad
closes #6 closes #7
Richardk2n Jul 3, 2021
bb875df
update link
Richardk2n Jul 3, 2021
5bd1a3b
closes #8
Richardk2n Jul 3, 2021
7d18bbf
Create mypy.ini
Richardk2n Jul 3, 2021
997c318
Merge pull request #11 from Richardk2n/rename
Richardk2n Jul 3, 2021
a780119
version bump
Richardk2n Jul 3, 2021
12cdaa1
closes #15
Richardk2n Aug 15, 2021
c7a4d54
Switch to unittest mock
jspricke Sep 18, 2021
42491d8
Use subprocess to execute mypy / dmypy
meshy Dec 2, 2021
102f495
Merge pull request #19 from jspricke/mock
Richardk2n Dec 4, 2021
d0e35fe
Replace capture_output shortcut with explicit args
meshy Dec 4, 2021
518c316
Merge pull request #23 from meshy/use-subprocess-to-run-mypy
Richardk2n Dec 4, 2021
b5c786e
version bump
Richardk2n Dec 4, 2021
a458c4b
Version bump again
Richardk2n Dec 4, 2021
2d7d0e8
test 3.10 as well
Richardk2n Dec 4, 2021
607190a
avoid 3.10 beeing read as 3.1
Richardk2n Dec 4, 2021
79057cc
Update setup.cfg
Richardk2n Dec 5, 2021
9cc7598
Add test fixture to mock out diagnostics cache
jpneverwas Nov 5, 2021
8e3a591
Add option to override command line
jpneverwas Nov 3, 2021
86ca6de
fixup! Add option to override command line
jpneverwas Dec 13, 2021
a83609e
fixup! fixup! Add option to override command line
jpneverwas Dec 14, 2021
75e6875
fix venvs
Richardk2n Dec 19, 2021
934851b
closes #18
Richardk2n Dec 19, 2021
299f46b
version bump
Richardk2n Dec 19, 2021
788c75a
Temporary fix to make tests run smoothly
Richardk2n Dec 19, 2021
a5f340e
version bump
Richardk2n Dec 19, 2021
88965e7
chore: add missing config setting and allow mypy 0.920
omgitsaheadcrab Dec 20, 2021
2086e84
chore: remove mypy version limit from setup.cfg
omgitsaheadcrab Dec 20, 2021
df2f52b
fix formatting
Richardk2n Dec 20, 2021
07a5bc2
Merge pull request #29 from omgitsaheadcrab/unreachable-code-settings
Richardk2n Dec 20, 2021
ce3844f
minor readability changes
Richardk2n Dec 21, 2021
c83a95d
Merge branch 'master' into overrides
Richardk2n Dec 21, 2021
2957354
black format
Richardk2n Dec 21, 2021
d1e32d5
more expressive name and doc
Richardk2n Dec 22, 2021
8bd3c39
Merge pull request #24 from jpneverwas/overrides
Richardk2n Dec 22, 2021
0c61489
version bump
Richardk2n Dec 22, 2021
ab00c9f
enforce isort
Richardk2n Jan 16, 2022
95009dd
update links
Richardk2n May 1, 2022
7382916
toml support
Richardk2n May 1, 2022
886fc3d
minor correction
Richardk2n May 1, 2022
06f841d
use toml
Richardk2n May 1, 2022
8b141d2
error in unittest
Richardk2n May 1, 2022
478562c
version bump
Richardk2n May 15, 2022
b99622b
Closes #36
Richardk2n Jul 2, 2022
89fb20d
Drop 3.6
Richardk2n Jul 2, 2022
6d52a87
Phase out old names
Richardk2n Jul 2, 2022
8e05a35
version bump
Richardk2n Jul 2, 2022
2951d14
correct flag
Richardk2n Jul 2, 2022
574c28e
ALso test on windows
Richardk2n Jul 2, 2022
6cdf1aa
test action
Richardk2n Jul 2, 2022
c9d3b28
action test2
Richardk2n Jul 2, 2022
49edaeb
fix action
Richardk2n Jul 2, 2022
3d0cac4
apply defaults
Richardk2n Jul 2, 2022
1a47bf3
fix tests
Richardk2n Jul 2, 2022
bcb77d1
Exclude non compatible test
Richardk2n Jul 3, 2022
5c1bd61
Format
Richardk2n Jul 3, 2022
03975b7
Expose generic mypy error as diagnostic
rchl Sep 16, 2022
2e5bfb9
create error or warning depending on process return code
rchl Sep 22, 2022
ae88f1d
black reformat
rchl Sep 22, 2022
d3b86ab
100 column limit
rchl Sep 22, 2022
20db63a
Detect all errors
Richardk2n Oct 9, 2022
f12354d
Merge pull request #40 from rchl/fix/generic-error
Richardk2n Oct 9, 2022
81cf8f4
version bump
Richardk2n Oct 9, 2022
cff0e19
Create new config option 'config_names'
hetmankp Oct 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

defaults:
run:
shell: bash

jobs:

testCode:

strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.7", "3.8", "3.9", "3.10"]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --show-source --statistics
- name: Check black formatting
run: |
# stop the build if black detect any changes
black --check .
- name: Check isort sorting
run: |
# stop the build if isort detect any changes
isort . --check --diff
- name: Test with pytest
run: |
pytest

testUploadability:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test with rstcheck
run: |
rstcheck README.rst
- name: Build and check
run: |
python setup.py sdist bdist_wheel
twine check dist/*
31 changes: 31 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package

on:
release:
types: [created]

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/Lucas-C/pre-commit-hooks-markup
rev: v1.0.1
hooks:
- id: rst-linter
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2017 Tom van Ommeren
Copyright (c) 2022 Richard Kellnberger

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
include README.rst
include versioneer.py
include pyls-mypy/_version.py
118 changes: 95 additions & 23 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,47 +1,119 @@
Mypy plugin for PYLS
Mypy plugin for PYLSP
======================

.. image:: https://badge.fury.io/py/pyls-mypy.svg
:target: https://badge.fury.io/py/pyls-mypy
.. image:: https://badge.fury.io/py/pylsp-mypy.svg
:target: https://badge.fury.io/py/pylsp-mypy

.. image:: https://travis-ci.org/tomv564/pyls-mypy.svg?branch=master
:target: https://travis-ci.org/tomv564/pyls-mypy
.. image:: https://github.com/python-lsp/pylsp-mypy/workflows/Python%20package/badge.svg?branch=master
:target: https://github.com/python-lsp/pylsp-mypy/

This is a plugin for the Palantir's Python Language Server (https://github.com/palantir/python-language-server)
This is a plugin for the `Python LSP Server`_.

It, like mypy, requires Python 3.2 or newer.
.. _`Python LSP Server`: https://github.com/python-lsp/python-lsp-server

It, like mypy, requires Python 3.7 or newer.


Installation
------------

Install into the same virtualenv as pyls itself.
Install into the same virtualenv as python-lsp-server itself.

``pip install pyls-mypy``
``pip install pylsp-mypy``

Configuration
-------------

``live_mode`` (default is True) provides type checking as you type.
This writes to a tempfile every time a check is done. Turning off ``live_mode`` means you must save your changes for mypy diagnostics to update correctly.

``dmypy`` (default is False) executes via ``dmypy run`` rather than ``mypy``.
This uses the ``dmypy`` daemon and may dramatically improve the responsiveness of the ``pylsp`` server, however this currently does not work in ``live_mode``. Enabling this disables ``live_mode``, even for conflicting configs.

``strict`` (default is False) refers to the ``strict`` option of ``mypy``.
This option often is too strict to be useful.

As mypy is unaware of what file path is being checked, there are limitations with live_mode
- Imports cannot be followed correctly
- Stub files are not validated correctly
``overrides`` (default is ``[True]``) specifies a list of alternate or supplemental command-line options.
This modifies the options passed to ``mypy`` or the mypy-specific ones passed to ``dmypy run``. When present, the special boolean member ``True`` is replaced with the command-line options that would've been passed had ``overrides`` not been specified. Later options take precedence, which allows for replacing or negating individual default options (see ``mypy.main:process_options`` and ``mypy --help | grep inverse``).

Turning off live_mode means you must save your changes for mypy diagnostics to update correctly.
``config_names`` (default is ``[]``) specifies alternate file names under which the mypy configuration may be found.

Depending on your editor, the configuration should be roughly like this:
This project supports the use of ``pyproject.toml`` for configuration. It is in fact the preferred way. Using that your configuration could look like this:

::

[tool.pylsp-mypy]
enabled = true
live_mode = true
strict = true

A ``pyproject.toml`` does not conflict with the legacy config file given that it does not contain a ``pylsp-mypy`` section. The following explanation uses the syntax of the legacy config file. However, all these options also apply to the ``pyproject.toml`` configuration (note the lowercase bools).
Depending on your editor, the configuration (found in a file called pylsp-mypy.cfg in your workspace or a parent directory) should be roughly like this for a standard configuration:

::

"pyls":
{
"plugins":
{
"pyls_mypy":
{
"enabled": true,
"live_mode": false
}
}
"enabled": True,
"live_mode": True,
"strict": False
}

With ``dmypy`` enabled your config should look like this:

::

{
"enabled": True,
"live_mode": False,
"dmypy": True,
"strict": False
}

With ``overrides`` specified (for example to tell mypy to use a different python than the currently active venv), your config could look like this:

::

{
"enabled": True,
"overrides": ["--python-executable", "/home/me/bin/python", True]
}

With ``config_files`` your config could look like this:

::

{
"enabled": True,
"config_files": [".config/mypy.ini"]
}


Developing
-------------

Install development dependencies with (you might want to create a virtualenv first):

::

pip install -r requirements.txt

The project is formatted with `black`_. You can either configure your IDE to automatically format code with it, run it manually (``black .``) or rely on pre-commit (see below) to format files on git commit.

The project is formatted with `isort`_. You can either configure your IDE to automatically sort imports with it, run it manually (``isort .``) or rely on pre-commit (see below) to sort files on git commit.

The project uses two rst tests in order to assure uploadability to pypi: `rst-linter`_ as a pre-commit hook and `rstcheck`_ in a GitHub workflow. This does not catch all errors.

This project uses `pre-commit`_ to enforce code-quality. After cloning the repository install the pre-commit hooks with:

::

pre-commit install

After that pre-commit will run `all defined hooks`_ on every ``git commit`` and keep you from committing if there are any errors.

.. _black: https://github.com/psf/black
.. _isort: https://github.com/PyCQA/isort
.. _rst-linter: https://github.com/Lucas-C/pre-commit-hooks-markup
.. _rstcheck: https://github.com/myint/rstcheck
.. _pre-commit: https://pre-commit.com/
.. _all defined hooks: .pre-commit-config.yaml
9 changes: 0 additions & 9 deletions pyls_mypy/__init__.py

This file was deleted.

Loading