diff --git a/src/tito/builder/__init__.py b/src/tito/builder/__init__.py index 1c58d60..4d89864 100644 --- a/src/tito/builder/__init__.py +++ b/src/tito/builder/__init__.py @@ -1,5 +1,8 @@ # Import our builders so they can be referenced in config as tito.builder.Class # regardless of which submodule they're in. + +# flake8: noqa + from tito.builder.main import \ Builder, \ NoTgzBuilder, \ diff --git a/src/tito/builder/main.py b/src/tito/builder/main.py index 9a15ba8..6d6599c 100644 --- a/src/tito/builder/main.py +++ b/src/tito/builder/main.py @@ -867,7 +867,6 @@ class MeadBuilder(Builder): else: self.maven_args.append('-q') - def tgz(self): self._setup_sources() @@ -1060,18 +1059,18 @@ class MockBuilder(Builder): def _build_in_mock(self): if not self.speedup: print("Initializing mock...") - output = run_command("mock %s -r %s --init" % (self.mock_cmd_args, self.mock_tag)) + run_command("mock %s -r %s --init" % (self.mock_cmd_args, self.mock_tag)) else: print("Skipping mock --init due to speedup option.") print("Installing deps in mock...") - output = run_command("mock %s -r %s %s" % ( + run_command("mock %s -r %s %s" % ( self.mock_cmd_args, self.mock_tag, self.srpm_location)) print("Building RPMs in mock...") - output = run_command('mock %s -r %s --rebuild %s' % + run_command('mock %s -r %s --rebuild %s' % (self.mock_cmd_args, self.mock_tag, self.srpm_location)) mock_output_dir = os.path.join(self.rpmbuild_dir, "mockoutput") - output = run_command("mock %s -r %s --copyout /builddir/build/RPMS/ %s" % + run_command("mock %s -r %s --copyout /builddir/build/RPMS/ %s" % (self.mock_cmd_args, self.mock_tag, mock_output_dir)) # Copy everything mock wrote out to /tmp/tito: diff --git a/src/tito/cli.py b/src/tito/cli.py index 79680fd..b133151 100644 --- a/src/tito/cli.py +++ b/src/tito/cli.py @@ -16,12 +16,11 @@ Tito's Command Line Interface import sys import os -import random from optparse import OptionParser from tito.common import find_git_root, error_out, debug, get_class_by_name, \ - BUILDCONFIG_SECTION, DEFAULT_BUILDER, BUILDCONFIG_SECTION, DEFAULT_TAGGER, \ + DEFAULT_BUILDER, BUILDCONFIG_SECTION, DEFAULT_TAGGER, \ create_builder, get_project_name, get_relative_project_dir, \ DEFAULT_BUILD_DIR, run_command, tito_config_dir from tito.compat import RawConfigParser, getstatusoutput, getoutput @@ -29,7 +28,7 @@ from tito.exception import TitoException # Hack for Python 2.4, seems to require we import these so they get compiled # before we try to dynamically import them based on a string name. -import tito.tagger +import tito.tagger # NOQA TITO_PROPS = "tito.props" RELEASERS_CONF_FILENAME = "releasers.conf" diff --git a/src/tito/common.py b/src/tito/common.py index 55e0bc0..7ef4af1 100644 --- a/src/tito/common.py +++ b/src/tito/common.py @@ -514,7 +514,7 @@ def check_tag_exists(tag, offline=False): debug("Local tag SHA1: %s" % tag_sha1) try: - repo_url = get_git_repo_url() + get_git_repo_url() except: sys.stderr.write('Warning: remote.origin do not exist. Assuming --offline, for remote tag checking.\n') return @@ -593,7 +593,7 @@ def replace_spec_release(file_name, release): if m: print("%s%s" % (m.group(1), release)) else: - print line + print(line) def scrape_version_and_release(template_file_name): diff --git a/src/tito/compat.py b/src/tito/compat.py index 3acd850..6969a82 100644 --- a/src/tito/compat.py +++ b/src/tito/compat.py @@ -10,6 +10,9 @@ # Red Hat trademarks are not licensed under GPLv2. No permission is # granted to use or replicate Red Hat trademarks that are incorporated # in this software or its documentation. + +# flake8: noqa + """ Compatibility library for Python 2.4 up through Python 3. """ diff --git a/src/tito/release/__init__.py b/src/tito/release/__init__.py index 5201321..1fdd18d 100644 --- a/src/tito/release/__init__.py +++ b/src/tito/release/__init__.py @@ -1,3 +1,5 @@ +# flake8: noqa + from tito.release.main import \ Releaser, \ RsyncReleaser, \ diff --git a/src/tito/release/distgit.py b/src/tito/release/distgit.py index ab727c2..1d2c65a 100644 --- a/src/tito/release/distgit.py +++ b/src/tito/release/distgit.py @@ -412,7 +412,7 @@ class DistGitMeadReleaser(DistGitReleaser): print("Syncing local repo with %s" % self.mead_scm) try: run_command("git push %s %s" % (self.mead_scm, self.builder.build_tag)) - except RunCommandException, e: + except RunCommandException as e: if "rejected" in e.output: if self._ask_yes_no("The remote rejected a push. Force push? [y/n] ", False): run_command("git push --force %s %s" % (self.mead_scm, self.builder.build_tag)) diff --git a/src/tito/tagger/__init__.py b/src/tito/tagger/__init__.py index e8d68c4..a7f911d 100644 --- a/src/tito/tagger/__init__.py +++ b/src/tito/tagger/__init__.py @@ -1,3 +1,5 @@ +# flake8: noqa + from tito.tagger.main import \ VersionTagger, \ ReleaseTagger, \ diff --git a/src/tito/tagger/main.py b/src/tito/tagger/main.py index 5d0a38f..3a3b50f 100644 --- a/src/tito/tagger/main.py +++ b/src/tito/tagger/main.py @@ -251,15 +251,15 @@ class VersionTagger(ConfigObject): subprocess.call(editor.split() + [name]) os.lseek(fd, 0, 0) - file = os.fdopen(fd) + f = os.fdopen(fd) - for line in file.readlines(): + for line in f.readlines(): if not line.startswith("#"): out_f.write(line) - output = file.read() + output = f.read() - file.close() + f.close() os.unlink(name) if not found_changelog: diff --git a/test/functional/build_gitannex_tests.py b/test/functional/build_gitannex_tests.py index e200ac0..1095fc5 100644 --- a/test/functional/build_gitannex_tests.py +++ b/test/functional/build_gitannex_tests.py @@ -24,7 +24,7 @@ from os.path import join from functional.fixture import TitoGitTestFixture, tito -from tito.compat import * +from tito.compat import * # NOQA from tito.common import run_command from tito.builder import GitAnnexBuilder diff --git a/test/functional/builder_tests.py b/test/functional/builder_tests.py index e6142c7..0555705 100644 --- a/test/functional/builder_tests.py +++ b/test/functional/builder_tests.py @@ -14,9 +14,8 @@ import os import tempfile -from os.path import join from tito.builder import Builder -from tito.common import * +from tito.common import run_command from tito.compat import RawConfigParser from functional.fixture import TitoGitTestFixture, tito diff --git a/test/functional/fetch_tests.py b/test/functional/fetch_tests.py index a15183a..de3301e 100644 --- a/test/functional/fetch_tests.py +++ b/test/functional/fetch_tests.py @@ -23,7 +23,7 @@ import tempfile from os.path import join from tito.common import run_command, tito_config_dir -from tito.compat import * +from tito.compat import * # NOQA from functional.fixture import TitoGitTestFixture, tito EXT_SRC_PKG = "extsrc" diff --git a/test/functional/multiproject_tests.py b/test/functional/multiproject_tests.py index beeab57..3b8dc33 100644 --- a/test/functional/multiproject_tests.py +++ b/test/functional/multiproject_tests.py @@ -22,7 +22,7 @@ from os.path import join from tito.common import run_command, \ get_latest_tagged_version, tag_exists_locally -from functional.fixture import * +from functional.fixture import TitoGitTestFixture, tito # A location where we can safely create a test git repository. # WARNING: This location will be destroyed if present. diff --git a/test/functional/release_copr_tests.py b/test/functional/release_copr_tests.py index 042b43f..759f226 100644 --- a/test/functional/release_copr_tests.py +++ b/test/functional/release_copr_tests.py @@ -17,7 +17,7 @@ Functional Tests for the CoprReleaser. from functional.fixture import TitoGitTestFixture -from tito.compat import * +from tito.compat import * # NOQA from tito.release import CoprReleaser PKG_NAME = "releaseme" diff --git a/test/functional/release_yum_tests.py b/test/functional/release_yum_tests.py index 072559b..e77e076 100644 --- a/test/functional/release_yum_tests.py +++ b/test/functional/release_yum_tests.py @@ -24,7 +24,7 @@ from os.path import join from functional.fixture import TitoGitTestFixture, tito -from tito.compat import * +from tito.compat import * # NOQA from tito.common import run_command PKG_NAME = "releaseme" diff --git a/test/functional/singleproject_tests.py b/test/functional/singleproject_tests.py index 4367ea2..da89fac 100644 --- a/test/functional/singleproject_tests.py +++ b/test/functional/singleproject_tests.py @@ -13,8 +13,8 @@ # in this software or its documentation. import os -from tito.common import * -from tito.builder import * +from tito.builder import Builder, UpstreamBuilder +from tito.common import tag_exists_locally, check_tag_exists from tito.release import Releaser from tito.compat import getoutput from functional.fixture import TitoGitTestFixture, tito diff --git a/test/unit/__init__.py b/test/unit/__init__.py index 664f62d..9f185ab 100644 --- a/test/unit/__init__.py +++ b/test/unit/__init__.py @@ -14,7 +14,7 @@ from contextlib import contextmanager from mock import mock_open, patch from StringIO import StringIO -from itertools import repeat + @contextmanager def open_mock(content, **kwargs): @@ -30,4 +30,4 @@ def open_mock(content, **kwargs): rv.content_out = lambda: content_out.getvalue() rv.__iter__.return_value = iter(stream.readlines()) rv.read.return_value = stream.read() - yield rv \ No newline at end of file + yield rv diff --git a/test/unit/common_tests.py b/test/unit/common_tests.py index 387ff7d..2780afc 100644 --- a/test/unit/common_tests.py +++ b/test/unit/common_tests.py @@ -13,15 +13,18 @@ # in this software or its documentation. """ Pure unit tests for tito's common module. """ -from tito.common import * -from tito import common +from tito.common import (replace_version, find_spec_like_file, increase_version, + search_for, compare_version, run_command_print, find_wrote_in_rpmbuild_output, + render_cheetah, increase_zstream, reset_release, find_file_with_extension, + normalize_class_name, extract_sha1, BugzillaExtractor + ) import unittest -from mock import Mock, patch, call, mock_open +from mock import Mock, patch, call +from textwrap import dedent from unit import open_mock -from textwrap import dedent class CommonTests(unittest.TestCase): @@ -167,26 +170,26 @@ class CommonTests(unittest.TestCase): HelloWorld Hello World """) - with open_mock(content) as fh: + with open_mock(content): results = search_for("foo", r"(Hello\s+World)", r"(HelloWorld)") - self.assertEquals(("Hello World",) , results[0]) - self.assertEquals(("HelloWorld",) , results[1]) + self.assertEquals(("Hello World",), results[0]) + self.assertEquals(("HelloWorld",), results[1]) def test_search_for_gets_first_match(self): content = dedent(""" HelloWorld Hello World """) - with open_mock(content) as fh: + with open_mock(content): results = search_for("foo", r"(Hello.*)") - self.assertEquals(("HelloWorld",) , results[0]) + self.assertEquals(("HelloWorld",), results[0]) def test_search_for_no_match(self): content = dedent(""" HelloWorld Goodbye World """) - with open_mock(content) as fh: + with open_mock(content): self.assertRaises(SystemExit, search_for, "foo", r"(NoMatch)") @@ -228,6 +231,7 @@ class CheetahRenderTest(unittest.TestCase): self.assertEquals(call("/tmp/*.cheetah"), mock_glob.mock_calls[0]) self.assertEquals(call("temp_pickle"), mock_unlink.mock_calls[0]) + class VersionMathTest(unittest.TestCase): def test_increase_version_minor(self): line = "1.0.0" diff --git a/test/unit/fixture.py b/test/unit/fixture.py index ab00ff8..aeacb65 100644 --- a/test/unit/fixture.py +++ b/test/unit/fixture.py @@ -14,7 +14,7 @@ import os import unittest -from tito.compat import * +from tito.compat import * # NOQA UNIT_DIR = os.path.abspath(os.path.dirname(__file__)) REPO_DIR = os.path.join(UNIT_DIR, '..', '..') diff --git a/test/unit/pep8_tests.py b/test/unit/pep8_tests.py index 72250ea..d992339 100644 --- a/test/unit/pep8_tests.py +++ b/test/unit/pep8_tests.py @@ -22,7 +22,8 @@ http://docs.python.org/3.3/reference/lexical_analysis.html """ import pep8 -from unit.fixture import * +from tito.compat import * # NOQA +from unit.fixture import TitoUnitTestFixture class TestPep8(TitoUnitTestFixture): diff --git a/test/unit/test_build_target_parser.py b/test/unit/test_build_target_parser.py index b236333..df1a5a2 100644 --- a/test/unit/test_build_target_parser.py +++ b/test/unit/test_build_target_parser.py @@ -1,7 +1,7 @@ import unittest from tito.buildparser import BuildTargetParser -from tito.compat import * +from tito.compat import * # NOQA from tito.exception import TitoException diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..4258557 --- /dev/null +++ b/tox.ini @@ -0,0 +1,10 @@ +# ignore errors: +# E12* are continuation line indention related +# E501 is line too long +# See http://pep8.readthedocs.org/en/latest/intro.html#id1 + +[flake8] +ignore=E124,E125,E127,E128,E501 +# Exclude the build directory that distutils creates +exclude=build/* +max-line-length=120