Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use flake8, fix errors N804, N805 #214

Merged
merged 6 commits into from Feb 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -49,6 +49,7 @@ tox.ini
# Coverage files (./bin/coverage_report.py)
.coverage
covhtml/
htmlcov/

# Built doc files (cd docs; make html)
docs/_build/
Expand Down
3 changes: 3 additions & 0 deletions .travis.yml
Expand Up @@ -29,10 +29,13 @@ matrix:
- python: 3.4
install:
- travis_wait pip install .[exports,plot,interactive,gmpy]
# see https://gitlab.com/pycqa/flake8/issues/121
- pip install git+https://gitlab.com/pycqa/flake8.git@a8aac560
- pip install sphinx numpydoc pytest-cov
env:
- SYMPY_GROUND_TYPES=gmpy1
script:
- python setup.py flake8
- py.test --cov sympy sympy/polys
- sphinx-build -W -b html docs build/sphinx/html
after_success:
Expand Down
3 changes: 2 additions & 1 deletion CONTRIBUTING.rst
Expand Up @@ -47,7 +47,8 @@ All work should be submitted via `Pull Requests (PR)`_.
6. Usually, it's good idea to be sure that all tests
pass and you don't break anything, so please run::

$ ./setup.py test
$ python setup.py flake8
$ python setup.py test

License
-------
Expand Down
1 change: 0 additions & 1 deletion docs/conf.py
Expand Up @@ -9,7 +9,6 @@
# All configuration values have a default value; values that are commented out
# serve to show the default value.

import sys
import os
import sympy

Expand Down
12 changes: 0 additions & 12 deletions docs/modules/utilities/iterables.rst
Expand Up @@ -2,18 +2,6 @@
Iterables
=========

cartes
------

Returns the cartesian product of sequences as a generator.

Examples::
>>> from sympy.utilities.iterables import cartes
>>> list(cartes([1,2,3], 'ab'))
[(1, 'a'), (1, 'b'), (2, 'a'), (2, 'b'), (3, 'a'), (3, 'b')]



variations
----------

Expand Down
4 changes: 2 additions & 2 deletions examples/advanced/curvilinear_coordinates.py
Expand Up @@ -9,8 +9,8 @@
tensor, Laplace operator, ...
"""

from sympy import var, sin, cos, pprint, Matrix, eye, trigsimp, Eq, \
Function, simplify, sinh, cosh, expand, symbols
from sympy import (sin, cos, pprint, Matrix, eye, Eq, Function, simplify,
sinh, cosh, expand, symbols)


def laplace(f, g_inv, g_det, X):
Expand Down
4 changes: 2 additions & 2 deletions examples/advanced/fem.py
Expand Up @@ -15,8 +15,8 @@

"""

from sympy import symbols, Symbol, factorial, Rational, zeros, div, eye, \
integrate, diff, pprint, reduced
from sympy import (symbols, Symbol, factorial, Rational, zeros, eye,
integrate, diff, pprint, reduced)

x, y, z = symbols('x,y,z')

Expand Down
4 changes: 2 additions & 2 deletions examples/advanced/gibbs_phenomenon.py
Expand Up @@ -13,8 +13,8 @@
* http://en.wikipedia.org/wiki/Gibbs_phenomena
"""

from sympy import var, sqrt, integrate, conjugate, seterr, Abs, pprint, I, pi,\
sin, cos, sign, lambdify, Integral, S
from sympy import (var, sqrt, integrate, conjugate, Abs, pprint, pi,
sin, cos, lambdify, Integral)

x = var("x", extended_real=True)

Expand Down
1 change: 0 additions & 1 deletion examples/advanced/pidigits.py
Expand Up @@ -7,7 +7,6 @@
"""

from mpmath import libmp, pi
from mpmath import functions as mpf_funs

import math
from time import clock
Expand Down
4 changes: 2 additions & 2 deletions examples/advanced/relativity.py
Expand Up @@ -13,8 +13,8 @@

"""

from sympy import (exp, Symbol, sin, Rational, Derivative, dsolve, Function,
Matrix, Eq, pprint, Pow, classify_ode, solve)
from sympy import (exp, Symbol, sin, dsolve, Function, Matrix, Eq,
pprint, solve)


def grad(f, X):
Expand Down
1 change: 0 additions & 1 deletion examples/all.py
Expand Up @@ -44,7 +44,6 @@
sympy_dir = os.path.join(os.path.dirname(this_file), "..")
sympy_dir = os.path.normpath(sympy_dir)
sys.path.insert(0, sympy_dir)
import sympy

TERMINAL_EXAMPLES = [
"intermediate.infinite_1d_box",
Expand Down
3 changes: 2 additions & 1 deletion examples/beginner/plotting_nice_plot.py
Expand Up @@ -5,8 +5,9 @@
Demonstrates simple plotting.
"""

from sympy import Symbol, cos, sin, log, tan
from sympy import cos, sin, log, tan
from sympy.plotting.plot import plot3d

from sympy.abc import x, y


Expand Down
2 changes: 1 addition & 1 deletion examples/intermediate/mplot2d.py
Expand Up @@ -9,7 +9,7 @@

from sample import sample

from sympy import log, pi, sqrt, sin, Symbol
from sympy import sqrt, Symbol
from sympy.core.compatibility import is_sequence
from sympy.external import import_module

Expand Down
2 changes: 1 addition & 1 deletion examples/intermediate/mplot3d.py
Expand Up @@ -9,7 +9,7 @@

from sample import sample

from sympy import sin, Symbol
from sympy import Symbol
from sympy.external import import_module


Expand Down
2 changes: 1 addition & 1 deletion examples/intermediate/partial_differential_eqs.py
Expand Up @@ -5,7 +5,7 @@
Demonstrates various ways to solve partial differential equations
"""

from sympy import symbols, Eq, Function, pde_separate, pprint, sin, cos, latex
from sympy import symbols, Eq, Function, pde_separate, pprint, sin, cos
from sympy import Derivative as D


Expand Down
2 changes: 1 addition & 1 deletion examples/intermediate/vandermonde.py
Expand Up @@ -6,7 +6,7 @@
* http://en.wikipedia.org/wiki/Vandermonde_matrix
"""

from sympy import Matrix, pprint, Rational, sqrt, symbols, Symbol, zeros
from sympy import Matrix, pprint, Rational, symbols, Symbol, zeros


def symbol_gen(sym_str):
Expand Down
30 changes: 30 additions & 0 deletions setup.cfg
@@ -1,3 +1,33 @@
[flake8]
# E122 - continuation line missing indentation or outdented
# E124 - closing bracket does not match visual indentation
# E127 - continuation line over-indented for visual indent
# E128 - continuation line under-indented for visual indent
# E201 - whitespace after '['
# E202 - whitespace before ']'
# E221 - multiple spaces before operator
# E402 - module level import not at top of file
# E226 - missing whitespace around arithmetic operator
# E241 - multiple spaces after ','
# W503 - line break before binary operator
# F401 - 'foo' imported but unused
# F402 - import 'foo' from line bar shadowed by loop variable
# F403 - 'from ... import *' used; unable to detect undefined names
# F811 - redefinition of unused 'foo' from line bar
# F821 - undefined name 'foo'
# F823 - local variable 'foo' referenced before assignment
# F841 - local variable 'bar' is assigned to but never used
# N801 - class names should use CapWords convention
# N802 - function name should be lowercase
# N803 - argument name should be lowercase
# 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
ignore = E122,E124,E127,E128,E201,E202,E221,E226,E241,E402,W503,F401,F402,F403,F811,F821,F823,F841,N801,N802,N803,N806,N811,N812,N813,N814
max-line-length = 7000
exclude = build,.eggs
[pep8]
# E122 - continuation line missing indentation or outdented
# E124 - closing bracket does not match visual indentation
Expand Down
73 changes: 5 additions & 68 deletions setup.py
@@ -1,31 +1,7 @@
#!/usr/bin/env python
"""
Setuptools-based setup script for SymPy.

This uses Setuptools (http://pythonhosted.org/setuptools/setuptools.html),
a collection of enhancements to the standard Python distutils.
For the easiest installation just type the command (you'll probably
need root privileges for that):

python setup.py install

This will install the library in the default location. For instructions on
how to customize the install procedure read the output of:

python setup.py --help install

In addition, there are some other commands:

python setup.py clean -> will clean all trash (*.pyc and stuff)
python setup.py test -> will run the complete test suite
python setup.py audit -> will run pyflakes checker on source code

To get a full list of avaiable commands, read the output of:

python setup.py --help-commands

Or, if all else fails, feel free to write to the sympy list at
sympy@googlegroups.com and ask for help.
This script uses Setuptools (http://pythonhosted.org/setuptools/), a
collection of enhancements to the standard Python distutils.
"""

import sys
Expand All @@ -41,38 +17,6 @@
sys.exit(-1)


class audit(Command):
"""Audits SymPy's source code for following issues:
- Names which are used but not defined or used before they are defined.
- Names which are redefined without having been used.
"""

description = "Audit SymPy source with PyFlakes"
user_options = []

def initialize_options(self):
self.all = None

def finalize_options(self):
pass

def run(self):
import os
try:
import pyflakes.scripts.pyflakes as flakes
except ImportError:
print("In order to run the audit, you need to have PyFlakes installed.")
sys.exit(-1)
dirs = (os.path.join(*d) for d in (m.split('.') for m in find_packages()))
warns = 0
for dir in dirs:
for filename in os.listdir(dir):
if filename.endswith('.py') and filename != '__init__.py':
warns += flakes.checkPath(os.path.join(dir, filename))
if warns > 0:
print("Audit finished with total %d warnings" % warns)


class clean(Command):
"""Cleans *.pyc and debian trashs, so you should get the same copy as
is in the VCS.
Expand Down Expand Up @@ -135,13 +79,7 @@ def finalize_options(self):

def run_tests(self):
import pytest
import pep8
errno = pytest.main(self.pytest_args)
if errno != 0:
sys.exit(errno)
del sys.argv[:]
errno = pep8._main()
sys.exit(errno)
return pytest.main(self.pytest_args)


exec(open('sympy/release.py').read())
Expand All @@ -160,8 +98,7 @@ def run_tests(self):
packages=find_packages(),
ext_modules=[],
cmdclass={'test': test,
'clean': clean,
'audit': audit},
'clean': clean},
classifiers=[
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
Expand All @@ -173,7 +110,7 @@ def run_tests(self):
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.4',
],
tests_require=['pytest>=2.7.0', 'pep8>=1.6.0', 'pytest-cov'],
tests_require=['pytest>=2.7.0', 'flake8', 'pep8-naming', 'pytest-cov'],
install_requires=['mpmath>=0.19', 'decorator', 'strategies>=0.2.3'],
setup_requires=['setuptools>=5.5.1,<=19.4', 'pip>=6.0'],
extras_require={
Expand Down
1 change: 0 additions & 1 deletion sympy/categories/diagram_drawing.py
Expand Up @@ -91,7 +91,6 @@
from itertools import chain
from sympy.core.compatibility import iterable
from sympy.printing import latex
from sympy.utilities.decorator import doctest_depends_on


class _GrowableGrid(object):
Expand Down
2 changes: 1 addition & 1 deletion sympy/combinatorics/graycode.py
Expand Up @@ -276,7 +276,7 @@ def current(self):
return rv.rjust(self.n, '0')

@classmethod
def unrank(self, n, rank):
def unrank(cls, n, rank):
"""
Unranks an n-bit sized Gray code of rank k. This method exists
so that a derivative GrayCode class can define its own code of
Expand Down
2 changes: 1 addition & 1 deletion sympy/combinatorics/partitions.py
Expand Up @@ -235,7 +235,7 @@ def RGS(self):
[i for p in partition for i in p], key=default_sort_key)])

@classmethod
def from_rgs(self, rgs, elements):
def from_rgs(cls, rgs, elements):
"""
Creates a set partition from a restricted growth string.

Expand Down
14 changes: 7 additions & 7 deletions sympy/combinatorics/permutations.py
Expand Up @@ -1431,7 +1431,7 @@ def transpositions(self):
return res

@classmethod
def from_sequence(self, i, key=None):
def from_sequence(cls, i, key=None):
"""Return the permutation needed to obtain ``i`` from the sorted
elements of ``i``. If custom sorting is desired, a key can be given.

Expand Down Expand Up @@ -1586,7 +1586,7 @@ def next_lex(self):
return _af_new(perm)

@classmethod
def unrank_nonlex(self, n, r):
def unrank_nonlex(cls, n, r):
"""
This is a linear time unranking algorithm that does not
respect lexicographic order [3].
Expand Down Expand Up @@ -2345,7 +2345,7 @@ def rank_trotterjohnson(self):
return rank

@classmethod
def unrank_trotterjohnson(self, size, rank):
def unrank_trotterjohnson(cls, size, rank):
"""
Trotter Johnson permutation unranking. See [4] section 2.4.

Expand Down Expand Up @@ -2617,7 +2617,7 @@ def get_positional_distance(self, other):
return sum(abs(a[i] - b[i]) for i in range(len(a)))

@classmethod
def josephus(self, m, n, s=1):
def josephus(cls, m, n, s=1):
"""Return as a permutation the shuffling of range(n) using the Josephus
scheme in which every m-th item is selected until all have been chosen.
The returned permutation has elements listed by the order in which they
Expand Down Expand Up @@ -2666,7 +2666,7 @@ def josephus(self, m, n, s=1):
return Perm(perm)

@classmethod
def from_inversion_vector(self, inversion):
def from_inversion_vector(cls, inversion):
"""
Calculates the permutation from the inversion vector.

Expand All @@ -2693,7 +2693,7 @@ def from_inversion_vector(self, inversion):
return _af_new(perm)

@classmethod
def random(self, n):
def random(cls, n):
"""
Generates a random permutation of length ``n``.

Expand All @@ -2712,7 +2712,7 @@ def random(self, n):
return _af_new(perm_array)

@classmethod
def unrank_lex(self, size, rank):
def unrank_lex(cls, size, rank):
"""
Lexicographic permutation unranking.

Expand Down