Skip to main content

Statically check your Python code

Project description

py_static_check

py_static_check can statically check your Python code for a lot of common errors. It uses a modified pyflakes code and extends with following things:

  • Ability to specify what star imports resolve to (-s argument)

  • Ability to ignore unused import warnings (-i argument)

  • Better sorting of warnings/errors

For more information check out:

To install it do following:

sudo easy_install py_static_check

Here are some of the things py_static_check can do.

Catch undefined names, even for star imports

Example code:

from os import *

def function_with_error():
    print path
    print paths

star_imports.py:

import os
STAR_IMPORTS = {
    'os': os.__all__,
}

When ran with py_static_check:

$ py_static_check -s tests/star_import.py tests/undefined_name_star.py
tests/undefined_name.py:5: undefined name 'paths

Ignore not used warnings

Exampel code:

from os import path

When ran with py_static_check -i option:

$ py_static_check -i tests/ignore_not_used.py

$ py_static_check tests/ignore_not_used.py
tests/ignore_not_used.py:10: 'path' imported but unused

Assigned but never used

Like pyflakes it can catch a lot of errors, such as defining a variable without using it.

Exampel code:

def some_function():
    def inner_fn():
        local_var = ""

When ran with py_static_check:

$ py_static_check tests/assigned_but_never_used.py

tests/assigned_but_never_used.py:8: local variable 'local_var' is assigned to but never used

Copyright: 2011 by amix License: MIT.

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

py_static_check-1.1.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

py_static_check-1.1-py2.7.egg (21.9 kB view details)

Uploaded Source

File details

Details for the file py_static_check-1.1.tar.gz.

File metadata

File hashes

Hashes for py_static_check-1.1.tar.gz
Algorithm Hash digest
SHA256 1bbb75ea894ce28e069c02122f3ef4fabe5cf904ebbab259645956ab5b5e718d
MD5 4fecbc08dd726122880af0339ea25e98
BLAKE2b-256 2757e3553c8b5fa77921754429908579f7d9a3b7665d0ccf422a14565e82aeb7

See more details on using hashes here.

Provenance

File details

Details for the file py_static_check-1.1-py2.7.egg.

File metadata

File hashes

Hashes for py_static_check-1.1-py2.7.egg
Algorithm Hash digest
SHA256 bb7d88a9c7fe2417c3a9d6cc754b3a18523640709de91255908a3e20951dee01
MD5 bbe6b98f7a76615c4257ed92a88d697c
BLAKE2b-256 374a9b95f4b1ffed1f4ed3846e866b5fedba3f9cb0dddf973f0a5d974605b73e

See more details on using hashes here.

Provenance

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