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

Remove CodeQL, add flake8 #153

Merged
merged 6 commits into from
Jan 17, 2023
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
41 changes: 0 additions & 41 deletions .github/workflows/codeql.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@ repos:
hooks:
- id: pyupgrade
args: ["--py37-plus"]
- repo: https://github.com/pycqa/flake8
rev: 5.0.4 # 6.0.0 requires Python 3.8
hooks:
- id: flake8

exclude: doc/ext/sphinxarg
10 changes: 10 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
[bdist_wheel]
universal = 1

[flake8]
max_line_length = 100
# E203: whitespace before ':' (black / flake8 disagreement)
# W503: line break before binary operator (black / flake8 disagreement)
ignore=E203,W503
# E402: module level import not at top of file
# F405: may be undefined, or defined from star imports
# F403: from .manager import *' used; unable to detect undefined names
per-file-ignores = */__init__.py: F405,F403,E402
16 changes: 8 additions & 8 deletions zeekpkg/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,19 +419,19 @@ def _write_plugin_magic(self, ipkg):
os.rename(magic_path_disabled, magic_path)
except OSError as exception:
LOG.warning(
"could not enable plugin: %s: %s".format(
type(exception).__name__, exception
)
"could not enable plugin: %s %s",
type(exception).__name__,
exception,
)
else:
if os.path.exists(magic_path):
try:
os.rename(magic_path, magic_path_disabled)
except OSError as exception:
LOG.warning(
"could not disable plugin: %s: %s".format(
type(exception).__name__, exception
)
"could not disable plugin: %s %s",
type(exception).__name__,
exception,
)

def _read_manifest(self):
Expand Down Expand Up @@ -1257,8 +1257,8 @@ def remove(self, pkg_path):
try:
LOG.debug("removing link %s", link)
os.unlink(link)
except os.error as excpt:
LOG.warn("cannot remove link for %s", exec)
except os.error as err:
LOG.warn("cannot remove link for %s", err)

del self.installed_pkgs[pkg_to_remove.name]
self._write_manifest()
Expand Down
58 changes: 28 additions & 30 deletions zkg
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,27 @@ try:
except ImportError:
pass

from zeekpkg._util import (
delete_path,
make_dir,
make_symlink,
find_program,
read_zeek_config_line,
std_encoding,
)
from zeekpkg.package import (
TRACKING_METHOD_VERSION,
)
from zeekpkg.template import (
LoadError,
Template,
)
from zeekpkg.uservar import (
UserVar,
)

import zeekpkg

# For Zeek-bundled installation, prepend the Python path of the Zeek
# installation. This ensures we find the matching zeekpkg module
# first, avoiding potential conflicts with installations elsewhere on
Expand Down Expand Up @@ -85,27 +106,6 @@ 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 (
delete_path,
make_dir,
make_symlink,
find_program,
read_zeek_config_line,
std_encoding,
)
from zeekpkg.package import (
TRACKING_METHOD_VERSION,
)
from zeekpkg.template import (
LoadError,
Template,
)
from zeekpkg.uservar import (
UserVar,
)

import zeekpkg


def confirmation_prompt(prompt, default_to_yes=True):
yes = {"y", "ye", "yes"}
Expand Down Expand Up @@ -329,15 +329,15 @@ def create_config(args, configfile):
def active_git_branch(path):
try:
repo = git.Repo(path)
except git.exc.NoSuchPathError as error:
except git.exc.NoSuchPathError:
return None

if not repo.working_tree_dir:
return None

try:
rval = repo.active_branch
except TypeError as error:
except TypeError:
# return detached commit
rval = repo.head.commit

Expand All @@ -359,7 +359,7 @@ def is_local_git_repo(git_url):
# accessible, (2) it's not the root directory of a git repo.
git.Repo(git_url)
return True
except (git.exc.InvalidGitRepositoryError, git.exc.NoSuchPathError) as error:
except (git.exc.InvalidGitRepositoryError, git.exc.NoSuchPathError):
return False


Expand All @@ -368,7 +368,7 @@ def is_local_git_repo_dirty(git_url):
return False
try:
repo = git.Repo(git_url)
except git.exc.NoSuchPathError as error:
except git.exc.NoSuchPathError:
return False

return repo.is_dirty(untracked_files=True)
Expand Down Expand Up @@ -1536,11 +1536,9 @@ def cmd_upgrade(manager, args, config, configfile):

for info, next_version, _ in outdated_packages:
name = info.package.qualified_name()
bdir = name

if not manager.match_source_packages(name):
name = info.package.git_url
bdir = zeekpkg.package.name_from_path(name)

ipkg = manager.find_installed_package(name)
modifications = manager.modified_config_files(ipkg)
Expand Down Expand Up @@ -1918,7 +1916,7 @@ def cmd_info(manager, args, config, configfile):

for name in package_names:
info = manager.info(
name, version=args.version, prefer_installed=(args.nolocal != True)
name, version=args.version, prefer_installed=(not args.nolocal)
)

if info.package:
Expand Down Expand Up @@ -1968,7 +1966,7 @@ def cmd_info(manager, args, config, configfile):
print(f'\tmetadata (from version "{info.metadata_version}"):')

if len(info.metadata) == 0:
if args.json != True:
if not args.json:
print("\t\t<empty metadata file>")
else:
if args.json:
Expand All @@ -1987,7 +1985,7 @@ def cmd_info(manager, args, config, configfile):
# Skip the version that was already processed
if vers != info.metadata_version:
info2 = manager.info(
name, vers, prefer_installed=(args.nolocal != True)
name, vers, prefer_installed=(not args.nolocal)
)
pkginfo[name]["metadata"][info2.metadata_version] = dict()
if info2.metadata_file:
Expand Down