landscapeio / prospector Goto Github PK
View Code? Open in Web Editor NEWInspects Python source files and provides information about type and location of classes, methods etc
License: GNU General Public License v2.0
Inspects Python source files and provides information about type and location of classes, methods etc
License: GNU General Public License v2.0
The README says to see the supported tools section below, but this is actually another page in the documentation and there should probably be a link to that instead.
In order to add Prospector to my Ohloh "tools I actively use for development" list, I took advantage of their "you don't have to be a project manager to add an entry" feature. (It's also one more way people can discover Prospector and Landscape.io)
You'll probably want to declare yourself a project manager on this entry. (Among other things, it gives you the option of disallowing edits by random Joe Nobodies like me.)
https://www.ohloh.net/p/landscapeio-prospector
I've filled out everything I could but I highly recommend checking these pages to see if there's anything I missed:
Finally, while I think they're large and gaudy, Ohloh does have their own statistics widgets. (But only for GitHub Pages. They use <script>
tags)
Python supports multiple imports on the same line separated by commas: import os, sys
Prospector and Landscape.io need some way to say "I want 'veryhigh' strictness in general, but use 'medium' for PyLint and use this raw config file with pep8.py instead."
prospector -s medium
doesn't enforce PEP8 strictly enough but prospector -s high
makes PyLint too pedantic and makes PEP8 complain about "E401: multiple imports on one line", which I've ignored in my flake8 configuration.
As-is, I have to continue to enforce my PEP8 policy by leaving Travis-CI configured to run flake8 and fail the entire test run if the code fails the style check.
For pep8.py, might I suggest just restoring its ability to let a [pep8]
section in setup.cfg
or tox.ini
override the default values? (In other words, supply the prospector configuration via whatever mechanism pep8 --config
uses and make sure Prospector isn't confusing its idea of where the project's root directory is.)
The python-skeletons project has a lot of goals in common with prospector's attempts to adapt static analyis tools to particular frameworks. Ideally, pylint-django
and pylint-celery
could be subsumed into pylint-skeletons
, and prospector would include pylint-skeletons
.
This issue is a rather vague "investigate this" reminder rather than anything specific.
There is no such flag, right?
installed via pip,
executed via py26 in venv
$ python
Python 2.6.8 (unknown, Mar 9 2014, 22:16:00)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
$ prospector --version
prospector 0.7
have an error
$ prospector
Traceback (most recent call last):
File "/Users/iremizov/Py26/bin/prospector", line 9, in <module>
load_entry_point('prospector==0.7', 'console_scripts', 'prospector')()
File "/Users/iremizov/Py26/lib/python2.6/site-packages/prospector/run.py", line 312, in main
prospector.execute()
File "/Users/iremizov/Py26/lib/python2.6/site-packages/prospector/run.py", line 253, in execute
summary['time_taken'] = '%0.2f' % delta.total_seconds()
AttributeError: 'datetime.timedelta' object has no attribute 'total_seconds'
There seems to be an inconsistency when reporting column numbers: the pylint tool returns 0-based columns, while all other tools report 1-based columns (provided the column number is available, that is):
$ echo import sys >test.py
$ prospector -B -M test.py
Messages
========
test.py:
L1:1 None: frosted - E101
sys imported but unused
test.py:
L1:1 None: pyflakes - FL0001
'sys' imported but unused
test (test.py):
L1:0 None: pylint - W0611
Unused import sys
It's hard to make it part of CI because:
I'd suggest first to support exit code.
I've installed by cloning from git and then ran python setup.py install
Traceback (most recent call last):
File "/usr/local/bin/prospector", line 9, in <module>
load_entry_point('prospector==0.5.1', 'console_scripts', 'prospector')()
File "/usr/local/lib/python2.7/dist-packages/prospector-0.5.1-py2.7.egg/prospector/run.py", line 186, in main
summary, messages = prospector.execute()
File "/usr/local/lib/python2.7/dist-packages/prospector-0.5.1-py2.7.egg/prospector/run.py", line 131, in execute
tool.prepare(self.path, self.ignores, self.config, self.adaptors)
File "/usr/local/lib/python2.7/dist-packages/prospector-0.5.1-py2.7.egg/prospector/tools/pylint/__init__.py", line 83, in prepare
adaptor.adapt_pylint(linter)
File "/usr/local/lib/python2.7/dist-packages/prospector-0.5.1-py2.7.egg/prospector/adaptor/common.py", line 8, in adapt_pylint
linter.load_plugin_modules(['pylint_common'])
File "/usr/local/lib/python2.7/dist-packages/pylint-1.1.0-py2.7.egg/pylint/lint.py", line 357, in load_plugin_modules
module = load_module_from_name(modname)
File "/usr/local/lib/python2.7/dist-packages/logilab_common-0.61.0-py2.7.egg/logilab/common/modutils.py", line 125, in load_module_from_name
return load_module_from_modpath(dotted_name.split('.'), path, use_sys)
File "/usr/local/lib/python2.7/dist-packages/logilab_common-0.61.0-py2.7.egg/logilab/common/modutils.py", line 167, in load_module_from_modpath
mp_file, mp_filename, mp_desc = find_module(part, path)
ImportError: No module named pylint_common
So I tried:
sjuul@development01:~/workspace/oversight$ sudo pip install -U pylint-common
Requirement already up-to-date: pylint-common in /usr/local/lib/python2.7/dist-packages/pylint_common-0.1-py2.7.egg
Requirement already up-to-date: pylint>=1.0 in /usr/local/lib/python2.7/dist-packages/pylint-1.1.0-py2.7.egg (from pylint-common)
Requirement already up-to-date: astroid>=1.0 in /usr/local/lib/python2.7/dist-packages/astroid-1.0.1-py2.7.egg (from pylint-common)
Requirement already up-to-date: pylint-plugin-utils>=0.1 in /usr/local/lib/python2.7/dist-packages/pylint_plugin_utils-0.1.1-py2.7.egg (from pylint-common)
Requirement already up-to-date: logilab-common>=0.53.0 in /usr/local/lib/python2.7/dist-packages/logilab_common-0.61.0-py2.7.egg (from pylint>=1.0->pylint-common)
But that didn't help
Prospector should use existing pylint config if available
at https://landscape.io/github/fsr-itse/EvaP/95/modules/evap/evaluation/meta.py#L19 it says
def __new__(metacls, classname, bases, classDict):
Metaclass class method __new__ should have 'mcs' as first argument
first argument of a classmethod should be named 'cls'
so... yeah.
This is somewhat related to pre-commit/pre-commit#178
I'm working on setting up a Prospector hook for http://pre-commit.com/ (a handy git pre-commit hook manager). The way I'm configuring it, pre-commit runs prospector
via xargs
. See https://github.com/pre-commit/pre-commit/blob/master/pre_commit/languages/system.py
I'm currently setting the entry point to prospector as -n 1 prospector
so that pre-commit ends up running xargs -0 -n 1 prospector
, which then calls prospector once per input file. This ends up creating a lot of redundant summaries and message headers in the output, when I would rather just get the messages themselves. I can supply the -M
argument to suppress the summaries, but I still get the Messages
header once per file, even when there are no messages for that file.
My request is to add some sort of flag for either suppressing the Messages
header specifically, or for more generally controlling output verbosity.
If this seems reasonable, I'd be willing to work on it and submit a pull request. Alternatively, if there's a better way to do this or something obvious I'm missing, I would appreciate any help.
(my efforts so far are at https://github.com/guykisel/prospector-mirror [which could probably use a better project name])
(moving from landscapeio/landscape-issues#67)
Currently prospector looks for files with a .py
extension, but this could be a bit smarter. For example, first use mimetype
to look for text files, then inspect those for a python hashbang or other indications of python-ness.
If someone puts a virtualenvironment in the root of their project, prospector will attempt to check every package. It should detect virtualenvironment directories and skip them
please have a look at https://landscape.io/github/fsr-itse/EvaP/88/modules/evap/evaluation/models.py#L231. i'm pretty sure our code is not as broken as prospector suggests :)
Did some debug and found out that it tries to compare class pylint.checkers.base.BasicChecker
with instance of site-packages.pylint.checkers.base.BasicChecker
How I could fix it?
The change to use jayclassless/setopfconf removed the ability to specify the path from a command line option. This may be used by people already, so should be reinstated for backwards compatability (and possibly deprecated).
See #14
I get TypeError: unorderable types: str() > NoneType()
upon running prospector on requirements.txt. This is python 3.4 with prospector 0.7.
My requirements.txt: https://gist.github.com/374113a40502b04c5112
When Prospector is run on some python libraries, it simply exit out with message:
"Segmentation fault (core dumped)"
Sample libraries: pygtkspellcheck, Netzob, GladeBuilder, gtimelog
Please let me know if you need any further information.
Prospector is throwing exception for python package "django-http-proxy". Version of package is 0.3.2.
Below is the stack trace:
Traceback (most recent call last):
File "/usr/local/bin/prospector", line 9, in <module>
load_entry_point('prospector==0.6.4', 'console_scripts', 'prospector')()
File "/usr/local/lib/python3.4/dist-packages/prospector-0.6.4-py3.4.egg/prospector/run.py", line 190, in main
prospector = Prospector(config, paths[0])
File "/usr/local/lib/python3.4/dist-packages/prospector-0.6.4-py3.4.egg/prospector/run.py", line 34, in __init__
self._determine_adapters()
File "/usr/local/lib/python3.4/dist-packages/prospector-0.6.4-py3.4.egg/prospector/run.py", line 46, in _determine_adapters
for name, adaptor in autodetect_libraries(self.path):
File "/usr/local/lib/python3.4/dist-packages/prospector-0.6.4-py3.4.egg/prospector/autodetect.py", line 69, in autodetect_libraries
adaptor_names = find_from_path(path)
File "/usr/local/lib/python3.4/dist-packages/prospector-0.6.4-py3.4.egg/prospector/autodetect.py", line 35, in find_from_path
names |= find_from_path(item_path)
File "/usr/local/lib/python3.4/dist-packages/prospector-0.6.4-py3.4.egg/prospector/autodetect.py", line 35, in find_from_path
names |= find_from_path(item_path)
File "/usr/local/lib/python3.4/dist-packages/prospector-0.6.4-py3.4.egg/prospector/autodetect.py", line 38, in find_from_path
names |= find_from_imports(fip.read())
File "/usr/lib/python3.4/codecs.py", line 313, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 37: invalid start byte
Please let me know if you need any further details to look into this issue..
Could you please look into this ?
The summary is probably a lot more useful if it appears at the end of the output instead of the start.
diffcov automatically finds the diff lines that needs tests.
It also finds lint errors on diffs which is very useful for PRs.
Can prospector be given an option to check single files?
Having a single file mode would make building a prospector powered atom.io linter possible.
This is related to #56. It would be easier to wrap prospector in other tools (such as a git commit hook) if it could accept more than one path at a time.
I'm interested in implementing this myself and submitting it as a pull request, but I wouldn't mind if someone else with more free time does it instead.
This may be a little pathological but it's worth knowing about at least: if prospector is installed on the system, then installed into an activated virtualenv, the system version is used. If the virtualenv is deactivated then reactivated, the virtualenv version is used.
for ci-tools designed to parse pylint output
If you put the line number after the file, then will be much more useful to emacs users that use the compile command. This:
foo/__init__.py :
L5:1 None: pyflakes - FL0001
'ApiException' imported but unused
should be:
foo/__init__.py:5 :
L5:1 None: pyflakes - FL0001
'ApiException' imported but unused
The Python 3 Wall of Superpowers features the most downloaded 210 modules of PyPI. At the end of the list, there are still very popular packages like bottle, Zope or Pylons. Prospector should support all of them to help with many use cases.
The current README is becoming insufficient to explain all of the features of prospector, and is missing things like the motivation for the project and clarification of some behaviour. A nice big "Read the docs" page would be useful.
Currently, in code written to work in both Python 2.x and Python 3.x, the default strictness_medium
profile for prospector causes PyLint to return this error when run under Python 2.x:
run_tests (run_tests.py):
L41:0 : pylint - C0325
Unnecessary parens after 'print' keyword
On projects which use tox (it complements Travis-CI in the same way an offline copy of Prospector complements Landscape.io), the user is forced to choose between not inspecting files like setup.py in the root of the repository (which differs from my understanding of how Landscape.io does things) and a very awkward hack-around involving temporarily moving .tox
outside the project repository.
(Since letting it inspect .tox
takes forever and produces a flood of spurious errors from the project's dependencies in the virtualenvs)
There needs to be some kind of mechanism for ignoring folders and .tox
should be included in the default setting.
The radon project calculates the maintainability index of each python file.
It's a very useful metric to understand which modules are way too complex and need to be broken down into smaller modules.
We can use radon programmatically in order to calculate it.
There is no option to alter the Python path used to look for modules during the static analysis, thus causing a lot of "pylint - F0401 - Unable to import" error message.
Sometimes, as seen here: landscapeio/landscape-issues#36 , the sensible defaults are not helpful. There are several inclusions and exclusion rules that are essentially hardcoded. It'd be useful to expose all of these for edge cases (or rather, cases I forgot to think about!)
As a supported framework. :)
for CI tools
If I run prospector on this codebase, it hangs:
https://pypi.python.org/packages/source/S/SeriesMarker/SeriesMarker-0.0.3.tar.gz#md5=fc546636a48bda938988fea11bcd266b
Any ideas whats wrong?
For this code:
from twisted.internet.protocol import DatagramProtocol
class Class(DatagramProtocol):
def __init__(self, string, host, port):
self.transport.write(string, (host, port))
The inspector gives an error that class Class has no method transport. Whereas transport is defined by AbstractDatagramProtocol
which is inherited by DatagramProtocol
Update the documentation to include instructions on "how to get the best out of prospector" namely, install in a virtualenv alongside the project.
If a directory beginning with '.' is on your current path, then prospector will fail to generate any messages.
crate.io seems to have disappeared (see crateio/crate.io#18) so the badges should be removed from the README
To ignore a specific error/warning, as Prospector is a collection of tools, it could either:
Known exclusion in comment:
# pylint: disable=MESSAGE_ID_OR_KEY
# noqa
While using South and it's generated migrations, you'll get lot of automatically generated code with poor PEP-8 compliance, so it would be great to ignore them.
It could probably be done automatically once using Django (ignore */migrations/*.py
) or providing some generic way to define files to be skipped from checking.
The 1.1 release of pylint removed some checkers which prospector uses.
It would be helpful to issue new releases more often so we can try them and send feedback sooner.
just noticed that the linter appears to not display multiple instances of an error on the same page.
if i have
import json, pprint,
a = 1
b = 1
print a + b
I will get 2 errors, one E401, and one W0611 for pprint.
However I should have 3, E401, W0611 for json, and W0611 for pprint.
Prospector seems to be swallowing multiple instances of errors on the same line.
in https://landscape.io/github/fsr-itse/EvaP/95/modules/evap/evaluation/models.py#L330 i got five warnings for two disallowed spaces. one would have been enough :) maybe two would be acceptable (because there were two spaces disallowed), but not more please.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.