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 ruff #250

Merged
merged 2 commits into from
Oct 6, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ jobs:
- uses: hynek/setup-cached-uv@v2

- name: Run tox
env:
RUFF_OUTPUT_FORMAT: github
run: >
uvx --with=tox-uv --with=tox-gh-actions
tox run --installpkg dist/*.whl
Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from honcho import __version__

# -*- coding: utf-8 -*-
#
# honcho documentation build configuration file, created by
Expand All @@ -11,7 +13,6 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down Expand Up @@ -48,7 +49,6 @@
# built documents.
#
# The short X.Y version.
from honcho import __version__
version = __version__
# The full version, including alpha/beta/rc tags.
release = __version__
Expand Down
11 changes: 4 additions & 7 deletions honcho/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@
import logging
import os
import shlex
import sys
import signal
from collections import ChainMap
from collections import OrderedDict
from collections import defaultdict
import sys
from collections import ChainMap, OrderedDict, defaultdict

from honcho import __version__
from honcho import __version__, compat, environ
from honcho.environ import Env
from honcho.process import Popen
from honcho.manager import Manager
from honcho.printer import Printer
from honcho import compat, environ
from honcho.process import Popen

if sys.version_info < (3, 10):
from backports.entry_points_selectable import entry_points
Expand Down
7 changes: 2 additions & 5 deletions honcho/environ.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from collections import OrderedDict
from collections import defaultdict
from collections import namedtuple
import shlex
import os
import re

import shlex
from collections import OrderedDict, defaultdict, namedtuple

PROCFILE_LINE = re.compile(r'^([A-Za-z0-9_-]+):\s*(.+)$')

Expand Down
5 changes: 2 additions & 3 deletions honcho/export/runit.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import os

import jinja2

from honcho.export.base import BaseExport
from honcho.export.base import File
from honcho.export.base import dashrepl
from honcho.export.base import BaseExport, File, dashrepl


class Export(BaseExport):
Expand Down
3 changes: 1 addition & 2 deletions honcho/export/supervisord.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import jinja2

from honcho.export.base import BaseExport
from honcho.export.base import File
from honcho.export.base import BaseExport, File


class Export(BaseExport):
Expand Down
4 changes: 1 addition & 3 deletions honcho/export/systemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import jinja2

from honcho.export.base import BaseExport
from honcho.export.base import File
from honcho.export.base import dashrepl
from honcho.export.base import BaseExport, File, dashrepl


class Export(BaseExport):
Expand Down
4 changes: 1 addition & 3 deletions honcho/export/upstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import jinja2

from honcho.export.base import BaseExport
from honcho.export.base import File
from honcho.export.base import dashrepl
from honcho.export.base import BaseExport, File, dashrepl


class Export(BaseExport):
Expand Down
4 changes: 2 additions & 2 deletions honcho/manager.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import datetime
import queue
import multiprocessing
import queue
import signal
import sys

from .colour import get_colours
from .compat import ProcessManager
from .printer import Message, Printer
from .process import Process
from .printer import Printer, Message

KILL_WAIT = 5
SIGNALS = {
Expand Down
4 changes: 2 additions & 2 deletions honcho/printer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections import namedtuple
import sys
from collections import namedtuple

from .compat import ON_WINDOWS

Expand Down Expand Up @@ -76,7 +76,7 @@ def _colour_string(colour, s):
try:
import colorama
except ImportError:
def _colour_string(colour, s): # noqa
def _colour_string(colour, s):
return s
else:
colorama.init()
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ supervisord = "honcho.export.supervisord:Export"
systemd = "honcho.export.systemd:Export"
upstart = "honcho.export.upstart:Export"

[tool.ruff]
format.exclude = ["honcho/_version.py"]
lint.select = ["E4", "E7", "E9", "F", "I", "N", "RUF"]

[tool.setuptools.packages.find]
where = ["."]
include = ["honcho*"]
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def path(self, *args):

def run_honcho(self, args):
result = subprocess.run(
['honcho'] + args,
['honcho', *args],
cwd=self.root,
stdout=PIPE,
stderr=PIPE,
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/test_main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
import textwrap

import pytest


@pytest.mark.parametrize('testenv', [{
'Procfile': textwrap.dedent("""
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_start.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import textwrap
import sys
import textwrap

import pytest

Expand Down
4 changes: 2 additions & 2 deletions tests/test_environ.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@
# Unicode values
r"""
MYVAR=⋃ñᴉ—☪ó∂ǝ
""",
{'MYVAR': '⋃ñᴉ—☪ó∂ǝ'}
""", # noqa: RUF001
{'MYVAR': '⋃ñᴉ—☪ó∂ǝ'} # noqa: RUF001
],
[
# Unicode keys
Expand Down
7 changes: 2 additions & 5 deletions tests/test_export_base.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# -*- coding: utf-8 -*-

from mock import Mock
from mock import patch
import pytest
from mock import Mock, patch

from honcho.export.base import BaseExport
from honcho.export.base import dashrepl
from honcho.export.base import percentescape
from honcho.export.base import BaseExport, dashrepl, percentescape


class GiraffeExport(BaseExport):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_export_runit.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import collections

from mock import patch
import pytest
from mock import patch

from honcho.export.runit import Export

Expand All @@ -12,7 +12,7 @@

class TestExportRunit(object):
@pytest.fixture(autouse=True)
def exporter(self, request): # noqa
def exporter(self, request):
self.export = Export()

get_template_patcher = patch.object(Export, 'get_template')
Expand Down
3 changes: 1 addition & 2 deletions tests/test_export_supervisord.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from mock import MagicMock
from mock import patch
from mock import MagicMock, patch

from honcho.export.supervisord import Export

Expand Down
6 changes: 2 additions & 4 deletions tests/test_export_systemd.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import collections

from mock import MagicMock
from mock import call
from mock import patch
import pytest
from mock import MagicMock, call, patch

from honcho.export.systemd import Export

Expand All @@ -17,7 +15,7 @@

class TestExportSystemd(object):
@pytest.fixture(autouse=True)
def exporter(self, request): # noqa
def exporter(self, request):
self.export = Export()

self.master = MagicMock()
Expand Down
6 changes: 2 additions & 4 deletions tests/test_export_upstart.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import collections

from mock import MagicMock
from mock import call
from mock import patch
import pytest
from mock import MagicMock, call, patch

from honcho.export.upstart import Export

Expand All @@ -17,7 +15,7 @@

class TestExportUpstart(object):
@pytest.fixture(autouse=True)
def exporter(self, request): # noqa
def exporter(self, request):
self.export = Export()

self.master = MagicMock()
Expand Down
6 changes: 2 additions & 4 deletions tests/test_invocation.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import sys
import subprocess
import re

import pytest
import subprocess
import sys


def test_runpy_invoke():
Expand Down
7 changes: 3 additions & 4 deletions tests/test_manager.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import datetime
import queue
import multiprocessing
import queue

import pytest

from honcho.manager import SYSTEM_PRINTER_NAME, Manager
from honcho.printer import Message
from honcho.manager import Manager
from honcho.manager import SYSTEM_PRINTER_NAME

HISTORIES = {
'one': {
Expand Down Expand Up @@ -191,7 +190,7 @@ def find_line(self, data):

class TestManager(object):
@pytest.fixture(autouse=True)
def printer(self): # noqa
def printer(self):
self.p = FakePrinter()
self.m = Manager(printer=self.p)
self.m._clock = FakeClock()
Expand Down
3 changes: 2 additions & 1 deletion tests/test_printer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import datetime

import pytest

from honcho.printer import Printer, Message
from honcho.printer import Message, Printer


def fake_message(data, **kwargs):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_process.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime

import pytest

from honcho.process import Process
Expand Down Expand Up @@ -82,7 +83,7 @@ def close(self):
class TestProcess(object):

@pytest.fixture(autouse=True)
def queue(self): # noqa
def queue(self):
self.q = FakeQueue()

def test_ctor_cmd(self):
Expand Down
15 changes: 4 additions & 11 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
[tox]
envlist = py38, py39, py310, py311, py312, py313, pypy39, pypy310, lint

[flake8]
max-line-length = 110
exclude = .tox,.git,doc

[pytest]
minversion = 2.8
testpaths = tests
Expand Down Expand Up @@ -41,16 +37,13 @@ commands = coverage erase
[testenv:coverage]
deps = coverage
skip_install = true
commands =
coverage report
commands = coverage report

[testenv:lint]
deps =
flake8
pep8-naming
passenv = RUFF_OUTPUT_FORMAT
deps = ruff
skip_install = true
commands =
flake8 honcho
commands = ruff check {posargs}

[testenv:docs]
extras = docs
Expand Down