Commit 88aa7fa9 authored by Daniel Stender's avatar Daniel Stender

Import pep8-naming_0.4.1.orig.tar.xz

parent 74a3bc37
language: python
sudo: false
install:
pip install tox
script: tox
matrix:
include:
- env: TOXENV=py26
python: 2.6
- env: TOXENV=py27
python: 2.7
- env: TOXENV=py33
python: 3.3
- env: TOXENV=py34
python: 3.4
- env: TOXENV=py35
python: 3.5
- env: TOXENV=pypy
python: pypy
- env: TOXENV=pypy3
python: pypy3
- env: TOXENV=py27-flake8
python: 2.7
- env: TOXENV=py34-flake8
python: 3.4
Copyright © 2013 Florent Xicluna <florent.xicluna@gmail.com>
Licensed under the terms of the Expat License
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
include run_tests.py
recursive-include testsuite *.py
Metadata-Version: 1.1
Name: pep8-naming
Version: 0.3.3
Summary: Check PEP-8 naming conventions, plugin for flake8
Home-page: https://github.com/flintwork/pep8-naming
Author: Florent Xicluna
Author-email: florent.xicluna@gmail.com
License: Expat license
Description: PEP-8 Naming Conventions
========================
.. image:: https://badge.fury.io/py/pep8-naming.png
:target: http://badge.fury.io/py/pep8-naming
.. image:: https://travis-ci.org/flintwork/pep8-naming.png?branch=master
:target: https://travis-ci.org/flintwork/pep8-naming
.. image:: https://pypip.in/d/pep8-naming/badge.png
:target: https://crate.io/packages/pep8-naming?version=latest
Check the PEP-8 naming conventions.
This module provides a plugin for ``flake8``, the Python code checker.
(It replaces the plugin ``flint-naming`` for the ``flint`` checker.)
Installation
------------
You can install, upgrade, uninstall ``pep8-naming`` with these commands::
$ pip install pep8-naming
$ pip install --upgrade pep8-naming
$ pip uninstall pep8-naming
Plugin for Flake8
-----------------
When both ``flake8`` and ``pep8-naming`` are installed, the plugin is
available in ``flake8``::
$ flake8 --version
2.0 (pep8: 1.4.3, pyflakes: 0.6.1, naming: 0.2)
By default the plugin is enabled.
These error codes are emitted:
+------+-------------------------------------------------------+
| code | sample message |
+======+=======================================================+
| N801 | class names should use CapWords convention |
+------+-------------------------------------------------------+
| N802 | function name should be lowercase |
+------+-------------------------------------------------------+
| N803 | argument name should be lowercase |
+------+-------------------------------------------------------+
| N804 | first argument of a classmethod should be named 'cls' |
+------+-------------------------------------------------------+
| N805 | first argument of a method should be named 'self' |
+------+-------------------------------------------------------+
| N806 | variable in function should be lowercase |
+------+-------------------------------------------------------+
+------+-------------------------------------------------------+
| N811 | constant imported as non constant |
+------+-------------------------------------------------------+
| N812 | lowercase imported as non lowercase |
+------+-------------------------------------------------------+
| N813 | camelcase imported as lowercase |
+------+-------------------------------------------------------+
| N814 | camelcase imported as constant |
+------+-------------------------------------------------------+
Changes
-------
0.3.3 - 2015-06-30
``````````````````
* Fix bug where ignored names were not properly split into a list.
0.3.2 - 2015-06-14
``````````````````
* Fix bug trying to call ``split`` on a list.
0.3.1 - 2015-06-14
``````````````````
* Fix optparse exception resulting from trying to register an option twice.
0.3.0 - 2015-06-14
``````````````````
* Relaxed N806 checking for use with namedtuples
* Add ``--ignore-names`` which allows the user to specify a list of names to
ignore. By default this includes ``setUp``, ``tearDown``, ``setUpClass``,
and ``tearDownClass``.
0.2.2 - 2014-04-19
``````````````````
* Do not require ``setuptools`` in setup.py. It works around an issue
with ``pip`` and Python 3.
* ``__new__`` is now considered as ``classmethod`` implicitly
* Run unit tests on travis-ci.org for python2.6, 2.7, 3.2, and 3.3
* Add unit tests and support running them with setup.py
* Support Python 3.4
0.2.1 - 2013-02-22
``````````````````
* Do not require ``flake8``
0.2 - 2013-02-22
````````````````
* Rename project ``flint-naming`` to ``pep8-naming``
* Fix a crash when function argument is a tuple of tuples
0.1 - 2013-02-11
````````````````
* First release
Keywords: flake8 pep8 naming
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Quality Assurance
PEP-8 Naming Conventions
========================
.. image:: https://badge.fury.io/py/pep8-naming.png
:target: http://badge.fury.io/py/pep8-naming
.. image:: https://travis-ci.org/flintwork/pep8-naming.png?branch=master
:target: https://travis-ci.org/flintwork/pep8-naming
.. image:: https://pypip.in/d/pep8-naming/badge.png
:target: https://crate.io/packages/pep8-naming?version=latest
Check the PEP-8 naming conventions.
This module provides a plugin for ``flake8``, the Python code checker.
......@@ -69,6 +60,18 @@ These error codes are emitted:
Changes
-------
0.4.1 - 2016-06-26
``````````````````
* Note to self: Never do releases before ~0600 or coffee on a Sunday.
* Fix option parsing for Flake8 3.0 (store parsed value on class)
0.4.0 - 2016-06-26
``````````````````
* Fix integration with Flake8 3.0.0b1
* Start testing against Python 3.5
0.3.3 - 2015-06-30
``````````````````
......
Metadata-Version: 1.1
Name: pep8-naming
Version: 0.3.3
Summary: Check PEP-8 naming conventions, plugin for flake8
Home-page: https://github.com/flintwork/pep8-naming
Author: Florent Xicluna
Author-email: florent.xicluna@gmail.com
License: Expat license
Description: PEP-8 Naming Conventions
========================
.. image:: https://badge.fury.io/py/pep8-naming.png
:target: http://badge.fury.io/py/pep8-naming
.. image:: https://travis-ci.org/flintwork/pep8-naming.png?branch=master
:target: https://travis-ci.org/flintwork/pep8-naming
.. image:: https://pypip.in/d/pep8-naming/badge.png
:target: https://crate.io/packages/pep8-naming?version=latest
Check the PEP-8 naming conventions.
This module provides a plugin for ``flake8``, the Python code checker.
(It replaces the plugin ``flint-naming`` for the ``flint`` checker.)
Installation
------------
You can install, upgrade, uninstall ``pep8-naming`` with these commands::
$ pip install pep8-naming
$ pip install --upgrade pep8-naming
$ pip uninstall pep8-naming
Plugin for Flake8
-----------------
When both ``flake8`` and ``pep8-naming`` are installed, the plugin is
available in ``flake8``::
$ flake8 --version
2.0 (pep8: 1.4.3, pyflakes: 0.6.1, naming: 0.2)
By default the plugin is enabled.
These error codes are emitted:
+------+-------------------------------------------------------+
| code | sample message |
+======+=======================================================+
| N801 | class names should use CapWords convention |
+------+-------------------------------------------------------+
| N802 | function name should be lowercase |
+------+-------------------------------------------------------+
| N803 | argument name should be lowercase |
+------+-------------------------------------------------------+
| N804 | first argument of a classmethod should be named 'cls' |
+------+-------------------------------------------------------+
| N805 | first argument of a method should be named 'self' |
+------+-------------------------------------------------------+
| N806 | variable in function should be lowercase |
+------+-------------------------------------------------------+
+------+-------------------------------------------------------+
| N811 | constant imported as non constant |
+------+-------------------------------------------------------+
| N812 | lowercase imported as non lowercase |
+------+-------------------------------------------------------+
| N813 | camelcase imported as lowercase |
+------+-------------------------------------------------------+
| N814 | camelcase imported as constant |
+------+-------------------------------------------------------+
Changes
-------
0.3.3 - 2015-06-30
``````````````````
* Fix bug where ignored names were not properly split into a list.
0.3.2 - 2015-06-14
``````````````````
* Fix bug trying to call ``split`` on a list.
0.3.1 - 2015-06-14
``````````````````
* Fix optparse exception resulting from trying to register an option twice.
0.3.0 - 2015-06-14
``````````````````
* Relaxed N806 checking for use with namedtuples
* Add ``--ignore-names`` which allows the user to specify a list of names to
ignore. By default this includes ``setUp``, ``tearDown``, ``setUpClass``,
and ``tearDownClass``.
0.2.2 - 2014-04-19
``````````````````
* Do not require ``setuptools`` in setup.py. It works around an issue
with ``pip`` and Python 3.
* ``__new__`` is now considered as ``classmethod`` implicitly
* Run unit tests on travis-ci.org for python2.6, 2.7, 3.2, and 3.3
* Add unit tests and support running them with setup.py
* Support Python 3.4
0.2.1 - 2013-02-22
``````````````````
* Do not require ``flake8``
0.2 - 2013-02-22
````````````````
* Rename project ``flint-naming`` to ``pep8-naming``
* Fix a crash when function argument is a tuple of tuples
0.1 - 2013-02-11
````````````````
* First release
Keywords: flake8 pep8 naming
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Quality Assurance
README.rst
pep8ext_naming.py
setup.cfg
setup.py
pep8_naming.egg-info/PKG-INFO
pep8_naming.egg-info/SOURCES.txt
pep8_naming.egg-info/dependency_links.txt
pep8_naming.egg-info/entry_points.txt
pep8_naming.egg-info/not-zip-safe
pep8_naming.egg-info/top_level.txt
\ No newline at end of file
[flake8.extension]
N8 = pep8ext_naming:NamingChecker
[flint.extension]
N80 = pep8ext_naming:NamingChecker
N81 = pep8ext_naming:NamingChecker
# -*- coding: utf-8 -*-
"""Checker of PEP-8 Naming Conventions."""
import optparse
import re
import sys
from collections import deque
......@@ -10,7 +11,7 @@ try:
except ImportError:
from flake8.util import ast, iter_child_nodes
__version__ = '0.3.3'
__version__ = '0.4.1'
LOWERCASE_REGEX = re.compile(r'[_a-z][_a-z0-9]*$')
UPPERCASE_REGEX = re.compile(r'[_A-Z][_A-Z0-9]*$')
......@@ -58,6 +59,20 @@ BaseASTCheck = _ASTCheckMeta('BaseASTCheck', (object,),
{'__doc__': "Base for AST Checks.", 'err': _err})
def register_opt(parser, *args, **kwargs):
try:
# Flake8 3.x registration
parser.add_option(*args, **kwargs)
except (optparse.OptionError, TypeError):
# Flake8 2.x registration
parse_from_config = kwargs.pop('parse_from_config', False)
kwargs.pop('comma_separated_list', False)
kwargs.pop('normalize_paths', False)
parser.add_option(*args, **kwargs)
if parse_from_config:
parser.config_options.append(args[-1].lstrip('-'))
class NamingChecker(object):
"""Checker of PEP-8 Naming Conventions."""
name = 'naming'
......@@ -72,14 +87,20 @@ class NamingChecker(object):
@classmethod
def add_options(cls, parser):
ignored = ','.join(cls.ignore_names)
parser.add_option('--ignore-names', default=ignored,
action='store', type='string',
help="Names that should be ignored.")
parser.config_options.append('ignore-names')
register_opt(parser, '--ignore-names',
default=ignored,
action='store',
type='string',
parse_from_config=True,
comma_separated_list=True,
help='List of names the pep8-naming plugin should '
'ignore. (Defaults to %default)')
@classmethod
def parse_options(cls, options):
cls.ignore_names = SPLIT_IGNORED_RE.split(options.ignore_names)
cls.ignore_names = options.ignore_names
if not isinstance(cls.ignore_names, list):
cls.ignore_names = SPLIT_IGNORED_RE.split(options.ignore_names)
def run(self):
return self.visit_tree(self._node) if self._node else ()
......
import sys
import os
import pep8ext_naming
import re
PyCF_ONLY_AST = 1024
IS_PY3 = sys.version_info[0] == 3
IS_PY3_TEST = re.compile("^#\s*python3\s*only")
IS_PY2_TEST = re.compile("^#\s*python2\s*only")
def main():
print('Running pep8-naming tests')
test_count = 0
errors = 0
for filename in os.listdir('testsuite'):
with open(os.path.join('testsuite', filename)) as fd:
lines = list(fd)
if not is_test_allowed(lines):
continue
for testcase, codes in load_tests(lines):
test_count += 1
errors += test_file(filename, testcase, codes)
if errors == 0:
print("%s tests run successful" % test_count)
sys.exit(0)
else:
print("%i of %i tests failed" % (errors, test_count))
sys.exit(1)
def is_test_allowed(lines):
if IS_PY3 and any(IS_PY2_TEST.search(line) for line in lines[:3]):
return False
if not IS_PY3 and any(IS_PY3_TEST.search(line) for line in lines[:3]):
return False
return True
def load_tests(lines):
testcase = []
codes = []
for line in lines:
if line.startswith("#:"):
if testcase:
yield testcase, codes
del testcase[:]
codes = line.split()[1:]
else:
testcase.append(line)
if testcase and codes:
yield testcase, codes
def test_file(filename, lines, codes):
tree = compile(''.join(lines), '', 'exec', PyCF_ONLY_AST)
checker = pep8ext_naming.NamingChecker(tree, filename)
found_errors = []
for lineno, col_offset, msg, instance in checker.run():
found_errors.append(msg.split()[0])
if not found_errors and codes == ['Okay']:
return 0
errors = 0
for code in codes:
if code not in found_errors:
errors += 1
print("ERROR: %s not in %s" % (code, filename))
return errors
if __name__ == '__main__':
main()
[wheel]
universal = 1
[egg_info]
tag_date = 0
tag_build =
tag_svn_revision = 0
#: N801
class notok(object):
pass
#: N801
class Good(object):
class notok(object):
pass
pass
#: Okay
class VeryGood(object):
pass
#: Okay
def ok():
pass
#: N802
def __bad():
pass
#: N802
def bad__():
pass
#: N802
def __bad__():
pass
#: Okay
def _ok():
pass
#: Okay
def ok_ok_ok_ok():
pass
#: Okay
def _somehow_good():
pass
#: Okay
def go_od_():
pass
#: Okay
def _go_od_():
pass
#: N802
def NotOK():
pass
#: Okay
def _():
pass
#: Okay
class Foo(object):
def __method(self):
pass
#: Okay
class Foo(object):
def __method__(self):
pass
#: Okay
class ClassName(object):
def __method__(self):
pass
#: N802
class ClassName(object):
def notOk(self):
pass
#: N802
class ClassName(object):
def method(self):
def __bad():
pass
#: Okay
def setUp():
pass
#: Okay
def tearDown():
pass
#: Okay
class TestCase:
def setUp(self):
pass
def tearDown(self):
pass
def setUpClass(self):
pass
def tearDownClass(self):
pass
#: Okay
def b1():
pass
#: Okay
def b2(a):
pass
#: Okay
def b3(a, b, c, d):
pass
#: Okay
def b4(a, b, c, *fuck):
pass
#: Okay
def b5(*fuck):
pass
#: Okay
def b6(a, b, c, **kwargs):
pass
#: Okay
def b7(**kwargs):
pass
#: Okay
def b8(*args, **kwargs):
pass
#: Okay
def b9(a, b, c, *args, **kwargs):
pass
#: Okay
def b10(a, b, c=3, d=4, *args, **kwargs):
pass
#: N803
def b11(**BAD):
pass
#: N803
def b12(*BAD):
pass
#: N803
def b13(BAD, *VERYBAD, **EXTRABAD):
pass
#: N803
def b14(BAD):
pass
#: N803
class Test(object):
def __init__(self, BAD):
pass
@classmethod
def test(cls, BAD):
pass
# python2 only
#: Okay
def test(a, b, (good, verygood)):
pass
#: N803
def bad(a, b, (OHH, NOO)):
pass
# python3 only
#: Okay
def compare(a, b, *, key=None):
pass
#: N803
def compare(a, b, *, BAD=None):
pass
#: N803
def compare(a, b, *VERY, bad=None):
pass
#: N803
def compare(a, b, *ok, fine=None, **BAD):
pass
#: N804
class Foo(object):
@classmethod
def mmm(cls, ads):
pass
@classmethod
def bad(self, ads):
pass
@calling()
def test(self, ads):
pass
#: N805
class Foo(object):
def good(self, ads):
pass
def bad(ads, self):
pass
#: Okay
class Foo(object):
def __new__(cls):
return object.__new__(Foo)
#: Okay
class Foo(object):
@classmethod
def __prepare__(cls):
pass