mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-23 20:22:46 +00:00
Add flake8 configuration. Fix style issues.
- Remove assignments to unused variables - Rename variables shadowing builtins - Fix all flake8 errors in tests
This commit is contained in:
parent
ea0ea51552
commit
b0e85268c9
22 changed files with 61 additions and 39 deletions
|
@ -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, \
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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.
|
||||
"""
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# flake8: noqa
|
||||
|
||||
from tito.release.main import \
|
||||
Releaser, \
|
||||
RsyncReleaser, \
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# flake8: noqa
|
||||
|
||||
from tito.tagger.main import \
|
||||
VersionTagger, \
|
||||
ReleaseTagger, \
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
yield rv
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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, '..', '..')
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
10
tox.ini
Normal file
10
tox.ini
Normal file
|
@ -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
|
Loading…
Add table
Reference in a new issue