Skip to content

Commit

Permalink
Merge pull request #153 from cclauss/pyupgrade_py37-plus
Browse files Browse the repository at this point in the history
pyupgrade --py37-plus
  • Loading branch information
tonybaloney authored Jul 15, 2022
2 parents 8ad2767 + 6a53be1 commit 13545cb
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 25 deletions.
1 change: 0 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
Expand Down
1 change: 0 additions & 1 deletion src/wily/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: UTF-8 -*-
"""Main command line."""

import click
Expand Down
2 changes: 1 addition & 1 deletion src/wily/archivers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Revision:
deleted_files: List[str]


class BaseArchiver(object):
class BaseArchiver:
"""Abstract Archiver Class."""

def revisions(self, path: str, max_revisions: int) -> List[Revision]:
Expand Down
4 changes: 2 additions & 2 deletions src/wily/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def exists(config):
return False
index_path = pathlib.Path(config.cache_path) / "index.json"
if index_path.exists():
with open(index_path, "r") as out:
with open(index_path) as out:
index = json.load(out)
if index["version"] != __version__:
# TODO: Inspect the versions properly.
Expand Down Expand Up @@ -216,7 +216,7 @@ def get_default_metrics(config):
o = resolve_operator(operator)
if o.cls.default_metric_index is not None:
metric = o.cls.metrics[o.cls.default_metric_index]
default_metrics.append("{0}.{1}".format(o.cls.name, metric.name))
default_metrics.append(f"{o.cls.name}.{metric.name}")
return default_metrics


Expand Down
4 changes: 2 additions & 2 deletions src/wily/commands/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ def diff(config, files, metrics, changes_only=True, detail=True, revision=None):
)
)
else:
metrics_data.append("{0:n} -> {1:n}".format(current, new))
metrics_data.append(f"{current:n} -> {new:n}")
else:
if current == "-" and new == "-":
metrics_data.append("-")
else:
metrics_data.append("{0} -> {1}".format(current, new))
metrics_data.append(f"{current} -> {new}")
if has_changes or not changes_only:
results.append((file, *metrics_data))
else:
Expand Down
2 changes: 1 addition & 1 deletion src/wily/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def generate_cache_path(path):


@dataclass
class WilyConfig(object):
class WilyConfig:
"""
Wily configuration.
Expand Down
1 change: 0 additions & 1 deletion src/wily/lang.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Language/i18n support for the CLI."""
# -*- coding: UTF-8 -*-

import gettext
import os
Expand Down
2 changes: 1 addition & 1 deletion src/wily/operators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class OperatorLevel(Enum):
Object = 2


class BaseOperator(object):
class BaseOperator:
"""Abstract Operator Class."""

"""Name of the operator."""
Expand Down
6 changes: 3 additions & 3 deletions src/wily/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


@dataclass
class IndexedRevision(object):
class IndexedRevision:
"""Union of revision and the operators executed."""

revision: Revision
Expand Down Expand Up @@ -108,7 +108,7 @@ def store(self, config, archiver, stats):
return cache.store(config, archiver, self.revision, stats)


class Index(object):
class Index:
"""The index of the wily cache."""

operators = None
Expand Down Expand Up @@ -206,7 +206,7 @@ def save(self):
cache.store_archiver_index(self.config, self.archiver, data)


class State(object):
class State:
"""
The wily process state.
Expand Down
2 changes: 1 addition & 1 deletion test/integration/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import pytest
from click.testing import CliRunner
from git import Repo, Actor
from mock import patch
from unittest.mock import patch

import wily.__main__ as main
from wily.archivers import ALL_ARCHIVERS
Expand Down
2 changes: 1 addition & 1 deletion test/integration/test_graph.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
from mock import patch
from unittest.mock import patch
import tempfile
from click.testing import CliRunner

Expand Down
12 changes: 6 additions & 6 deletions test/unit/test_archivers.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import pathlib

import pytest
from mock import patch
from unittest.mock import patch

import wily.archivers
import wily.archivers.git as git
import wily.config


class MockAuthor(object):
class MockAuthor:
name = "Mr Test"
email = "[email protected]"


class MockStats(object):
class MockStats:
files = {}


TEST_AUTHOR = MockAuthor()
TEST_STATS = MockStats()


class MockCommit(object):
class MockCommit:
name_rev = "1234 bbb"
author = TEST_AUTHOR
committed_date = "1/1/1990"
Expand All @@ -33,11 +33,11 @@ def __init__(self, message):
self.message = message


class MockHead(object):
class MockHead:
is_detached = False


class MockRepo(object):
class MockRepo:
active_branch = "master"
bare = False
_is_dirty = False
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_build_unit.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from mock import patch
from unittest.mock import patch

import wily.commands.build as build
from wily.config import DEFAULT_CONFIG
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from click.testing import CliRunner
from mock import patch
from unittest.mock import patch
from pathlib import Path

import wily.__main__ as main
Expand Down
4 changes: 2 additions & 2 deletions test/unit/test_cyclomatic.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""
Tests for the cyclomatic complexity operator's ability to handle bad data from radon.
"""
import mock
from unittest import mock
import wily.operators.cyclomatic
from wily.config import DEFAULT_CONFIG


class MockCC(object):
class MockCC:
results = {}


Expand Down

0 comments on commit 13545cb

Please sign in to comment.