mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-12 07:44:16 +00:00
Merged tarek/flake8 into default
This commit is contained in:
commit
909820f1ce
5 changed files with 49 additions and 71 deletions
1
.hgtags
1
.hgtags
|
|
@ -19,3 +19,4 @@ ff671fabec71e85d32395c35c40a125432859e49 1.5
|
||||||
1184216fb3619680517d3f8386dc138ab2d5ee26 1.6.1
|
1184216fb3619680517d3f8386dc138ab2d5ee26 1.6.1
|
||||||
bca1826148f9ea22a89d9533d19a79ba6678293f 1.6.2
|
bca1826148f9ea22a89d9533d19a79ba6678293f 1.6.2
|
||||||
61b1bc18f258cf2647f4af29c3dfe48d268eeb0b 1.7.0
|
61b1bc18f258cf2647f4af29c3dfe48d268eeb0b 1.7.0
|
||||||
|
374b8e63d93b8743c3dad093bca449e01fdd287f 2.0
|
||||||
|
|
|
||||||
16
CHANGES.rst
16
CHANGES.rst
|
|
@ -1,16 +1,16 @@
|
||||||
CHANGES
|
CHANGES
|
||||||
=======
|
=======
|
||||||
|
|
||||||
2.0.0 - 2013-02-xx
|
2.0.0 - 2013-02-23
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
- Pyflakes errors are now prefixed by an ``F`` instead of an ``E``
|
- Pyflakes errors are prefixed by an ``F`` instead of an ``E``
|
||||||
- McCabe complexity warnings are now prefixed by a ``C`` instead of a ``W``
|
- McCabe complexity warnings are prefixed by a ``C`` instead of a ``W``
|
||||||
- Flake8 now supports extensions through entry points
|
- Flake8 supports extensions through entry points
|
||||||
- Due to the above support, we now **require** setuptools
|
- Due to the above support, we **require** setuptools
|
||||||
- We now have `documentation <https://flake8.readthedocs.org/>`_
|
- We publish the `documentation <https://flake8.readthedocs.org/>`_
|
||||||
- Fixes #13: pep8 and pyflakes are now external dependencies
|
- Fixes #13: pep8, pyflakes and mccabe become external dependencies
|
||||||
- Split run.py into main.py and hooks.py for better logic
|
- Split run.py into main.py, engine.py and hooks.py for better logic
|
||||||
- Expose our parser for our users
|
- Expose our parser for our users
|
||||||
- New feature: Install git and hg hooks automagically
|
- New feature: Install git and hg hooks automagically
|
||||||
- By relying on pyflakes (0.6.1), we also fixed #45 and #35
|
- By relying on pyflakes (0.6.1), we also fixed #45 and #35
|
||||||
|
|
|
||||||
5
docs/changes.rst
Normal file
5
docs/changes.rst
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
Changes
|
||||||
|
=======
|
||||||
|
|
||||||
|
.. include:: ../CHANGES.rst
|
||||||
|
:start-line: 3
|
||||||
|
|
@ -18,15 +18,20 @@ then this would look something like the following::
|
||||||
# ...
|
# ...
|
||||||
)
|
)
|
||||||
|
|
||||||
We used ``P10`` here, but in reality, you should check to prevent as much
|
|
||||||
future overlap as possible with other extensions. ``W`` and ``E`` followed by
|
|
||||||
three digits should be considered entirely reserved for pep8. ``F`` should be
|
|
||||||
considered reserved for Pyflakes and ``C`` for McCabe. Also, in anticipation
|
|
||||||
of possible pylint integration, ``W`` and ``E`` followed by four digits should
|
|
||||||
be considered reserved. We have no way of checking for those though, so while
|
|
||||||
we ask you not use them, we can not (currently) prevent you from doing so.
|
|
||||||
|
|
||||||
A Real Example: McCabe
|
If you intend to publish your extension, choose a unique code prefix
|
||||||
|
following the convention for :ref:`error codes <error-codes>`.
|
||||||
|
In addition, you can open a request in the `issue tracker
|
||||||
|
<https://bitbucket.org/tarek/flake8/issues>`_ to register the prefix in the
|
||||||
|
documentation.
|
||||||
|
|
||||||
|
.. TODO: describe the API required for the 3 kind of extensions:
|
||||||
|
* physical line checkers
|
||||||
|
* logical line checkers
|
||||||
|
* AST checkers
|
||||||
|
|
||||||
|
|
||||||
|
A real example: McCabe
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
Below is an example from mccabe_ for how to write your ``setup.py`` file for
|
Below is an example from mccabe_ for how to write your ``setup.py`` file for
|
||||||
|
|
@ -34,41 +39,17 @@ your Flake8 extension.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
# https://github.com/florentx/mccabe/blob/master/setup.py
|
# https://github.com/flintwork/mccabe/blob/0.2/setup.py#L38:L42
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import with_statement
|
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
|
# ...
|
||||||
def get_version(fname='mccabe.py'):
|
|
||||||
with open(fname) as f:
|
|
||||||
for line in f:
|
|
||||||
if line.startswith('__version__'):
|
|
||||||
return eval(line.split('=')[-1])
|
|
||||||
|
|
||||||
|
|
||||||
def get_long_description():
|
|
||||||
descr = []
|
|
||||||
for fname in ('README.rst',):
|
|
||||||
with open(fname) as f:
|
|
||||||
descr.append(f.read())
|
|
||||||
return '\n\n'.join(descr)
|
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='mccabe',
|
name='mccabe',
|
||||||
version=get_version(),
|
|
||||||
description="McCabe checker, plugin for flake8",
|
# ...
|
||||||
long_description=get_long_description(),
|
|
||||||
keywords='flake8 mccabe',
|
|
||||||
author='Tarek Ziade',
|
|
||||||
author_email='tarek@ziade.org',
|
|
||||||
maintainer='Florent Xicluna',
|
|
||||||
maintainer_email='florent.xicluna@gmail.com',
|
|
||||||
url='https://github.com/florentx/mccabe',
|
|
||||||
license='Expat license',
|
|
||||||
py_modules=['mccabe'],
|
|
||||||
zip_safe=False,
|
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'setuptools',
|
'setuptools',
|
||||||
],
|
],
|
||||||
|
|
@ -77,26 +58,17 @@ your Flake8 extension.
|
||||||
'C90 = mccabe:McCabeChecker',
|
'C90 = mccabe:McCabeChecker',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
classifiers=[
|
|
||||||
'Development Status :: 3 - Alpha',
|
# ...
|
||||||
'Environment :: Console',
|
|
||||||
'Intended Audience :: Developers',
|
|
||||||
'License :: OSI Approved :: MIT License',
|
|
||||||
'Operating System :: OS Independent',
|
|
||||||
'Programming Language :: Python',
|
|
||||||
'Programming Language :: Python :: 2',
|
|
||||||
'Programming Language :: Python :: 3',
|
|
||||||
'Topic :: Software Development :: Libraries :: Python Modules',
|
|
||||||
'Topic :: Software Development :: Quality Assurance',
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
In ``mccabe.py`` you can see that extra options are added to the parser when
|
In ``mccabe.py`` you can see that extra options are added to the parser when
|
||||||
flake8 registers the extensions:
|
flake8 registers the extension:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
# https://github.com/florentx/mccabe/blob/e88be51e0c6c2bd1b87d7a44b7e71b78fdc53959/mccabe.py#L225
|
# https://github.com/flintwork/mccabe/blob/0.2/mccabe.py#L225:L254
|
||||||
class McCabeChecker(object):
|
class McCabeChecker(object):
|
||||||
"""McCabe cyclomatic complexity checker."""
|
"""McCabe cyclomatic complexity checker."""
|
||||||
name = 'mccabe'
|
name = 'mccabe'
|
||||||
|
|
@ -131,6 +103,7 @@ flake8 registers the extensions:
|
||||||
Since that is the defined entry point in the above ``setup.py``, flake8 finds
|
Since that is the defined entry point in the above ``setup.py``, flake8 finds
|
||||||
it and uses it to register the extension.
|
it and uses it to register the extension.
|
||||||
|
|
||||||
|
|
||||||
.. links
|
.. links
|
||||||
.. _mccabe: https://github.com/florentx/mccabe
|
.. _mccabe: https://github.com/flintwork/mccabe
|
||||||
.. _PyPI: https://pypi.python.org/pypi/
|
.. _PyPI: https://pypi.python.org/pypi/
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ Documentation
|
||||||
buildout
|
buildout
|
||||||
setuptools
|
setuptools
|
||||||
warnings
|
warnings
|
||||||
|
changes
|
||||||
|
|
||||||
Original Projects
|
Original Projects
|
||||||
=================
|
=================
|
||||||
|
|
@ -23,5 +24,3 @@ projects:
|
||||||
- pep8: https://github.com/jcrocholl/pep8
|
- pep8: https://github.com/jcrocholl/pep8
|
||||||
- PyFlakes: https://launchpad.net/pyflakes
|
- PyFlakes: https://launchpad.net/pyflakes
|
||||||
- McCabe: http://nedbatchelder.com/blog/200803/python_code_complexity_microtool.html
|
- McCabe: http://nedbatchelder.com/blog/200803/python_code_complexity_microtool.html
|
||||||
|
|
||||||
.. include:: ../CHANGES.rst
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue