Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Commit

Permalink
Merging current master and cleaned up develop branch into develop, an…
Browse files Browse the repository at this point in the history
…d pruning various cruft to make develop branch the main clean one again
  • Loading branch information
carlio committed May 2, 2017
2 parents 0a8e402 + 628c523 commit 9febf8b
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 25 deletions.
14 changes: 11 additions & 3 deletions CHANGELOG.md
@@ -1,11 +1,19 @@
Prospector Changelog
=======

# Version 0.13.0
* Added HTML formatter
# Version 0.12.5
* [#207](https://github.com/landscapeio/prospector/pull/207) Fixed missing 'UnknownMessage' exception caused by recent pylint submodule changes
* Minor documentation formatting updates

# Version 0.12.1
# Version 0.12.4
* Panicky stapling of pyroma dependency until prospector is fied to not break with the new pyroma release

# Version 0.12.3
* [#190](https://github.com/landscapeio/prospector/pull/190) Pinning pydocstyle version for now until API compatability with newer versions can be written
* [#184](https://github.com/landscapeio/prospector/pull/184) Including the LICENCE file when building dists
* Fixed a crash in the profile_validator tool if an empty profile was found

# Version 0.12.1
* [#178](https://github.com/landscapeio/prospector/pull/178) Long paths no longer cause crash in Windows.
* [#173](https://github.com/landscapeio/prospector/issues/154) Changed from using pep8 to pycodestyle (which is what pep8 was renamed to)
* [#172](https://github.com/landscapeio/prospector/issues/172) Fixed non-ascii file handling for mccabe tool and simplified all python source file reading
Expand Down
3 changes: 2 additions & 1 deletion MANIFEST.in
@@ -1,4 +1,5 @@
include LICENSE
include prospector/blender_combinations.yaml
include prospector/profiles/profiles/*.yaml
graft prospector/formatters/templates
include LICENCE
include README.rst
10 changes: 5 additions & 5 deletions docs/profiles.rst
Expand Up @@ -109,20 +109,20 @@ Documentation Warnings
......................

By default prospector will not produce warnings about missing documentation or
`docstring styleguide violations <https://www.python.org/dev/peps/pep-0257/>`.
If you want to see these, use the `--doc-warnings` flag at runtime or include it in
`docstring styleguide violations <https://www.python.org/dev/peps/pep-0257/>`_.
If you want to see these, use the ``--doc-warnings`` flag at runtime or include it in
your profile::

doc-warnings: true

This will turn on the otherwise disabled `pep257` tool.
This will turn on the otherwise disabled ``pep257`` tool.


Test Warnings
.............

Prospector will not inspect unit tests and test files by default. You can
turn this on using the `--test-warnings` flag or in your profile::
turn this on using the ``--test-warnings`` flag or in your profile::

test-warnings: true

Expand All @@ -141,7 +141,7 @@ but you can turn it on using the ``--member-warnings`` flag or in a profile::
PEP8 Control
............

The strictness will turn on or off different messages generated by the `pep8.py <https://pypi.python.org/pypi/pep8>`
The strictness will turn on or off different messages generated by the `pep8.py <https://pypi.python.org/pypi/pep8>`_
tool depending on how picky they are. However, if you want to have the standard 'medium' strictness but get either
complete or zero pep8 style warnings, you can use a shorthand like below::

Expand Down
2 changes: 1 addition & 1 deletion prospector/__pkginfo__.py
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
__version_info__ = (0, 13, 0)
__version_info__ = (0, 12, 5)
__version__ = '.'.join(map(str, __version_info__))
10 changes: 8 additions & 2 deletions prospector/encoding.py
Expand Up @@ -17,7 +17,7 @@ def read_py_file(filepath):
# first just see if the file is properly encoded
try:
with open(filepath, 'rb') as f:
tokenize.detect_encoding(f.readline)
print(tokenize.detect_encoding(f.readline))
except SyntaxError as err:
# this warning is issued:
# (1) in badly authored files (contains non-utf8 in a comment line)
Expand All @@ -28,4 +28,10 @@ def read_py_file(filepath):
# with the encoding detected by inspecting the BOM
raise CouldNotHandleEncoding(filepath, err)

return tokenize.open(filepath).read()
try:
return tokenize.open(filepath).read()
# this warning is issued:
# (1) if uft-8 is specified, but latin1 is used with something like \x0e9 appearing
# (see http://stackoverflow.com/a/5552623)
except UnicodeDecodeError as err:
raise CouldNotHandleEncoding(filepath, err)
7 changes: 7 additions & 0 deletions prospector/exceptions.py
@@ -1,5 +1,12 @@
# -*- coding: utf-8 -*-

# We are trying to handle pylint changes in their exception classes
try:
# pylint < 1.7
from pylint.utils import UnknownMessage as UnknownMessageError
except ImportError:
# pylint >= 1.7
from pylint.exceptions import UnknownMessageError

class FatalProspectorException(Exception):

Expand Down
2 changes: 1 addition & 1 deletion prospector/finder.py
Expand Up @@ -160,7 +160,7 @@ def _find_paths(ignore, curpath, rootpath):
if os.path.isdir(fullpath):

# is it probably a virtualenvironment?
if is_virtualenv(fullpath):
if is_virtualenv(fullpath) or '.tox' in fullpath:
continue

# this is a directory
Expand Down
5 changes: 4 additions & 1 deletion prospector/profiles/profile.py
Expand Up @@ -356,4 +356,7 @@ def _load_profile(name_or_path, profile_path, shorthands_found=None,
inherit_order += new_il
shorthands_found |= new_sh

return contents_dict, inherit_order, shorthands_found
# note: a new list is returned here rather than simply using inherit_order to give astroid a
# clue about the type of the returned object, as otherwise it can recurse infinitely and crash,
# this meaning that prospector does not run on prospector cleanly!
return contents_dict, list(inherit_order), shorthands_found
2 changes: 1 addition & 1 deletion prospector/tools/profile_validator/__init__.py
Expand Up @@ -71,7 +71,7 @@ def add_message(code, message, setting):

if parsed is None:
# this happens if a completely empty profile is found
add_message(PROFILE_IS_EMPTY, "%s is a completely empty profile" % relative_filepath)
add_message(PROFILE_IS_EMPTY, "%s is a completely empty profile" % relative_filepath, 'entire-file')
return messages

for setting in ('doc-warnings', 'test-warnings', 'autodetect'):
Expand Down
4 changes: 2 additions & 2 deletions prospector/tools/pylint/__init__.py
Expand Up @@ -4,7 +4,7 @@
import sys
import os
from pylint.config import find_pylintrc
from pylint.utils import UnknownMessage
from prospector.exceptions import UnknownMessageError
from prospector.message import Message, Location
from prospector.tools.base import ToolBase
from prospector.tools.pylint.collector import Collector
Expand Down Expand Up @@ -41,7 +41,7 @@ def _prospector_configure(self, prospector_config, linter):
try:
linter.disable(msg_id)
# pylint: disable=pointless-except
except UnknownMessage:
except UnknownMessageError:
# If the msg_id doesn't exist in PyLint any more,
# don't worry about it.
pass
Expand Down
8 changes: 6 additions & 2 deletions prospector/tools/pylint/collector.py
@@ -1,6 +1,6 @@
from __future__ import absolute_import
from pylint.reporters import BaseReporter
from pylint.utils import UnknownMessage
from prospector.exceptions import UnknownMessageError
from prospector.message import Location, Message


Expand All @@ -13,14 +13,18 @@ def __init__(self, message_store):
self._message_store = message_store
self._messages = []

def handle_message(self, msg):
location = (msg.abspath, msg.module, msg.obj, msg.line, msg.column)
self.add_message(msg.msg_id, location, msg.msg)

def add_message(self, msg_id, location, msg):
# (* magic is acceptable here)
loc = Location(*location)
# At this point pylint will give us the code but we want the
# more user-friendly symbol
try:
msg_data = self._message_store.check_message_id(msg_id)
except UnknownMessage:
except UnknownMessageError:
# this shouldn't happen, as all pylint errors should be
# in the message store, but just in case we'll fall back
# to using the code.
Expand Down
11 changes: 5 additions & 6 deletions setup.py
Expand Up @@ -22,18 +22,17 @@
'pylint-celery>=0.3',
'pylint-django>=0.7.2',
'pylint-flask>=0.3',
'pylint-plugin-utils>=0.2.3',
'pylint-common>=0.2.2',
'pylint-plugin-utils>=0.2.6',
'pylint-common>=0.2.5',
'requirements-detector>=0.4.1',
'setoptconf>=0.2.0',
'dodgy>=0.1.9',
'pyyaml',
'mccabe>=0.5.0',
'pyflakes>=0.8.1',
'pycodestyle>=2.0.0',
'pycodestyle==2.0.0',
'pep8-naming>=0.3.3',
'pydocstyle>=0.1',
'Jinja2>=2.8',
'pydocstyle==1.0.0',
]

_PACKAGE_DATA = {
Expand Down Expand Up @@ -61,7 +60,7 @@
_OPTIONAL = {
'with_frosted': ('frosted>=1.4.1',),
'with_vulture': ('vulture>=0.6',),
'with_pyroma': ('pyroma>=2.0.2',),
'with_pyroma': ('pyroma==2.0.2',),
}
with_everything = [req for req_list in _OPTIONAL.values() for req in req_list]
_OPTIONAL['with_everything'] = sorted(with_everything)
Expand Down
Empty file added tests/encoding/__init__.py
Empty file.
11 changes: 11 additions & 0 deletions tests/encoding/test_encoding_detection.py
@@ -0,0 +1,11 @@
from __future__ import absolute_import
from prospector.encoding import read_py_file
import os
from unittest import TestCase


class InvalidUTF8Byte(TestCase):

def test_invalid_utf8_byte(self):
filepath = os.path.join(os.path.dirname(__file__), 'testdata/invalid-utf8-byte.py')
lines = read_py_file(filepath)

0 comments on commit 9febf8b

Please sign in to comment.