From 4551ae13f72bee68c50509570edead4e6e19bf00 Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Fri, 1 Mar 2024 16:05:09 -0700 Subject: [PATCH] Standardize on ruff for python formatting/linting via pre-commits --- .pre-commit-config.yaml | 12 +++++------- zeekpkg/__init__.py | 10 +++++----- zeekpkg/template.py | 5 ++--- zeekpkg/uservar.py | 1 + zkg | 10 +++++----- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9e764a2e..4683879e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,18 +10,16 @@ repos: exclude: testing/baselines - id: check-yaml - id: check-added-large-files -- repo: https://github.com/psf/black - rev: 23.1a1 - hooks: - - id: black - repo: https://github.com/asottile/pyupgrade rev: v3.15.1 hooks: - id: pyupgrade args: ["--py37-plus"] -- repo: https://github.com/pycqa/flake8 - rev: 5.0.4 # 6.0.0 requires Python 3.8 +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.3.0 hooks: - - id: flake8 + - id: ruff + args: [--fix] + - id: ruff-format exclude: doc/ext/sphinxarg diff --git a/zeekpkg/__init__.py b/zeekpkg/__init__.py index 63a4094f..52130ff7 100644 --- a/zeekpkg/__init__.py +++ b/zeekpkg/__init__.py @@ -10,12 +10,12 @@ import logging __version__ = "3.0.1-6" -__all__ = ["manager", "package", "source", "template", "uservar"] +__all__ = ["manager", "package", "source", "template", "uservar"] # noqa: F405 LOG = logging.getLogger(__name__) LOG.addHandler(logging.NullHandler()) -from .manager import * -from .package import * -from .source import * -from .uservar import * +from .manager import * # noqa: E402, F403 +from .package import * # noqa: E402, F403 +from .source import * # noqa: E402, F403 +from .uservar import * # noqa: E402, F403 diff --git a/zeekpkg/template.py b/zeekpkg/template.py index 87a87fb2..7e841cf2 100644 --- a/zeekpkg/template.py +++ b/zeekpkg/template.py @@ -1,6 +1,7 @@ """ A module for instantiating different types of Zeek packages. """ + import abc import configparser import re @@ -797,9 +798,7 @@ def _git_init(self, tmpl): """Initial commit. zkg {} created this package from template "{}" -using {}{}.""".format( - __version__, tmpl.name(), ver_info, features_info - ) +using {}{}.""".format(__version__, tmpl.name(), ver_info, features_info) ) diff --git a/zeekpkg/uservar.py b/zeekpkg/uservar.py index ac000715..6e455535 100644 --- a/zeekpkg/uservar.py +++ b/zeekpkg/uservar.py @@ -3,6 +3,7 @@ by packages that the user can provide in a variety of ways, including responses to zkg's input prompting. """ + import os import re import readline diff --git a/zkg b/zkg index 166ed991..5c18609b 100755 --- a/zkg +++ b/zkg @@ -85,26 +85,26 @@ ZKG_DEFAULT_SOURCE = "https://github.com/zeek/packages" # The default package template ZKG_DEFAULT_TEMPLATE = "https://github.com/zeek/package-template" -from zeekpkg._util import ( +from zeekpkg._util import ( # noqa: E402 delete_path, make_dir, find_program, read_zeek_config_line, std_encoding, ) -from zeekpkg.package import ( +from zeekpkg.package import ( # noqa: E402 BUILTIN_SCHEME, TRACKING_METHOD_VERSION, ) -from zeekpkg.template import ( +from zeekpkg.template import ( # noqa: E402 LoadError, Template, ) -from zeekpkg.uservar import ( +from zeekpkg.uservar import ( # noqa: E402 UserVar, ) -import zeekpkg +import zeekpkg # noqa: E402 def confirmation_prompt(prompt, default_to_yes=True):