Skip to main content

Python IDLE extension to preform mypy analysis on an open file

Project description

IdleMypyExtension

Python IDLE extension to preform 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 from the currently selected text with the "Remove Type Comments" command. Additionally, you can jump to the next comment this extension created in your file with the "Find Next Type Comment" command. Finally, you can add an inferred function signature to your file with the "Suggest Signature" command when you are close by a function definition.

Note: On use, creates folder mypy within the idle user directory. On linux systems, this is usually ~/.idlerc/mypy.

Installation

  1. Go to terminal and install with pip install idlemypyextension.
  2. Run command idlemypyextension. You will likely see a message saying idlemypyextension not in system registered extensions!. Run the command given to add idlemypyextension to your system's IDLE extension config file.
  3. Again run command idlemypyextension. This time, you should see the following output: Config should be good!.
  4. Open IDLE, go to Options -> Configure IDLE -> Extensions. If everything went well, alongside ZzDummy there should be and option called idlemypyextension. 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. Values under 5 will make no effect

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
    --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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

idlemypyextension-0.1.0.tar.gz (28.5 kB view details)

Uploaded Source

Built Distribution

idlemypyextension-0.1.0-py3-none-any.whl (26.2 kB view details)

Uploaded Python 3

File details

Details for the file idlemypyextension-0.1.0.tar.gz.

File metadata

  • Download URL: idlemypyextension-0.1.0.tar.gz
  • Upload date:
  • Size: 28.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0rc1

File hashes

Hashes for idlemypyextension-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3180b4fa5974382188c97d525e9e8d8e9e96db71687cf02dbfc69a87a2d39f7d
MD5 90bbdb9c8a733a15ece4474c25ff1da1
BLAKE2b-256 63d2a79186a3a720264895601da86d2f7ae216e0e3c1e7096dc72af60cb2922c

See more details on using hashes here.

File details

Details for the file idlemypyextension-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for idlemypyextension-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6374d90278e1c73431f2a776ff835189498f95904d4890b4ea1862eba1a78a87
MD5 542c4765b7d330cf0c33b4b9186f98df
BLAKE2b-256 e7b0d44a91a2b7af055281f2e804d6d5e0b092c1a1fae602ae74f8c5b9abce8a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page