Mypy daemon extension for Python IDLE
Project description
IdleMypyExtension
Python IDLE extension to perform mypy analysis on an open file
What does this extension do?
-
This IDLE extension hooks into the mypy daemon to type check the currently open file or provide a function signature suggestion for the nearest function to the top from the current input cursor location.
-
When type checking the currently open file with the "Type Check File" command, it will add comments to your code wherever mypy had something to say about about that line.
-
You can remove type comments added by this extension from the currently selected text with the "Remove Type Comments" command.
-
You can jump to the next comment this extension created in your file with the "Find Next Type Comment" command.
-
You can add an inferred function signature to your file with the "Suggest Signature" command when you are close by a function definition.
-
In the right click menu, you can inspect the type of the object your cursor is currently selecting. In this case, it adds type info comments about all of the objects you might be referring to. If you have a span of text selected, it will tell you about the type of only that span.
-
In the right click menu, you can go to the definition of the object your cursor is currently selecting.
-
In the right click menu, you can view the attributes mypy knows about of the object your cursor is currently selecting.
Note: On use, creates folder mypy within the idle user directory.
On Linux systems, this is usually ~/.idlerc/mypy.
Installation (Without root permissions)
- Go to terminal and install with
pip install idlemypyextension[user]. - Run command
idleuserextend; idlemypyextension. You should see the following output:Config should be good! Config should be good!. - Open IDLE, go to
Options->Configure IDLE->Extensions. If everything went well, alongsideZzDummythere should be and option calledidlemypyextension. This is where you can configure how idlemypyextension works.
Installation (Legacy, needs root permission)
- Go to terminal and install with
pip install idlemypyextension. - Run command
idlemypyextension. You will likely see a message sayingidlemypyextension not in system registered extensions!. Run the command given to add idlemypyextension to your system's IDLE extension config file. - Again run command
idlemypyextension. This time, you should see the following output:Config should be good!. - Open IDLE, go to
Options->Configure IDLE->Extensions. If everything went well, alongsideZzDummythere should be and option calledidlemypyextension. This is where you can configure how idlemypyextension works.
Information on options
action_max_sec controls how long an action is allowed to take at most,
in seconds. Default is "None".
For daemon_flags, see mypy --help for a list of valid flags.
This extension sets the following flags to be able to work properly:
--hide-error-context
--no-color-output
--show-absolute-path
--no-error-summary
--soft-error-limit=-1
--show-traceback
--cache-dir="~/.idlerc/mypy"
If you add the --show-column-numbers flag to daemon_flags, when using the
"Type Check File" command, it will add a helpful little ^ sign
in a new line below the location of the mypy message that provided a column
number, as long as that comment wouldn't break your file's indentation too much.
If you add the --show-error-codes flag to daemon_flags, when using the
"Type Check File" command, when it puts mypy's comments in your code, it will
tell you what type of error that comment is. For example, it would change the
error comment
# types: error: Incompatible types in assignment (expression has type "str", variable has type "int")
to
# types: assignment error: Incompatible types in assignment (expression has type "str", variable has type "int")
search_wrap toggles weather searching for next type comment will wrap
around or not.
suggest_replace toggles weather Suggest Signature will replace the
existing function definition or just add a comment with the suggested
definition
timeout_mins controls how long the mypy daemon will time out after,
in minutes.
should_restart_always toggles if the extension should restart dmypy
daemon before every run. May be helpful in some cases because of issues
with errors not being reported on subsequent runs, but this will slow
things down a lot.
force_base_ipc_request toggles if the extension should force using
mypy's provided inner process communication (IPC) module instead of
reimplementing IPC messaging but asynchronously from scratch. Note, this
is only effective on non-windows devices, because the way mypy does IPC
on windows is really complicated and doesn't have any benefits being
reimplemented over just using trio.wrap_file.
Annotating files from mypy error logs
I kept running into cases a lot where CI systems generate mypy error logs, and
I needed to fix those errors with my local copy. If you copy all the mypy
errors into a file, say error.txt, you can have idlemypyextension annotate
all of those files with a command like this:
idlemypyextension error.txt
which will open a blank IDLE window, hook into idlemypyextension, have it
add annotations to all files referenced in error log file, and then close
that temporary blank window, leaving all the files with errors still open.
If for some reason you need to run plain mypy instead of dmypy, you can do
mypy | idlemypyextension -
Links
- Source Code - https://github.com/CoolCat467/idlemypyextension.git
- Issues - https://github.com/CoolCat467/idlemypyextension/issues
- Pypi - https://pypi.org/project/idlemypyextension/
License
Code and documentation are available according to the GNU General Public License v3.0 (see LICENSE).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file idlemypyextension-1.4.2.tar.gz.
File metadata
- Download URL: idlemypyextension-1.4.2.tar.gz
- Upload date:
- Size: 91.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
425408ed95a6bcf8e1b5f72aebd9ef7df0440d905e88325d64efaed6e2c40cf5
|
|
| MD5 |
5ec53af686b7d3f34d199e8fed216a3a
|
|
| BLAKE2b-256 |
cfdb15c5e36d101a7d097995d2f153d5be3268bd304747cbf8a60b3f3be8fc82
|
Provenance
The following attestation bundles were made for idlemypyextension-1.4.2.tar.gz:
Publisher:
python-publish.yml on CoolCat467/idlemypyextension
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
idlemypyextension-1.4.2.tar.gz -
Subject digest:
425408ed95a6bcf8e1b5f72aebd9ef7df0440d905e88325d64efaed6e2c40cf5 - Sigstore transparency entry: 1277192638
- Sigstore integration time:
-
Permalink:
CoolCat467/idlemypyextension@5801678de3c8e70b1a1294b9d04fe7d8f7e269cc -
Branch / Tag:
refs/tags/v1.4.2 - Owner: https://github.com/CoolCat467
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@5801678de3c8e70b1a1294b9d04fe7d8f7e269cc -
Trigger Event:
release
-
Statement type:
File details
Details for the file idlemypyextension-1.4.2-py3-none-any.whl.
File metadata
- Download URL: idlemypyextension-1.4.2-py3-none-any.whl
- Upload date:
- Size: 74.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe9ea44f92e1216ee845f3c2dafc1523917602d2d63f71ac8741b8d151036521
|
|
| MD5 |
29cfcf29cd6fb5b31365b505b7046bd3
|
|
| BLAKE2b-256 |
604b4f08dcd03bad226ee3f45278c96e030cf1f0e37721cf20425ef64829bf02
|
Provenance
The following attestation bundles were made for idlemypyextension-1.4.2-py3-none-any.whl:
Publisher:
python-publish.yml on CoolCat467/idlemypyextension
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
idlemypyextension-1.4.2-py3-none-any.whl -
Subject digest:
fe9ea44f92e1216ee845f3c2dafc1523917602d2d63f71ac8741b8d151036521 - Sigstore transparency entry: 1277192710
- Sigstore integration time:
-
Permalink:
CoolCat467/idlemypyextension@5801678de3c8e70b1a1294b9d04fe7d8f7e269cc -
Branch / Tag:
refs/tags/v1.4.2 - Owner: https://github.com/CoolCat467
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@5801678de3c8e70b1a1294b9d04fe7d8f7e269cc -
Trigger Event:
release
-
Statement type: