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

Add pre-commit config #151

Merged
merged 7 commits into from Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
@@ -0,0 +1,2 @@
# Migrate code style to Black
99520f9201340d57d2cc9cf6f45992b994eff7c4
16 changes: 16 additions & 0 deletions .github/workflows/pre-commit.yml
@@ -0,0 +1,16 @@
name: pre-commit

on:
pull_request:
push:
branches: [master]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.7'
- uses: pre-commit/action@v3.0.0
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
@@ -0,0 +1,23 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
exclude: testing/baselines
- id: end-of-file-fixer
exclude: testing/baselines
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 23.1a1
hooks:
- id: black
ckreibich marked this conversation as resolved.
Show resolved Hide resolved
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: ["--py37-plus"]

exclude: doc/ext/sphinxarg
2 changes: 1 addition & 1 deletion CHANGES
Expand Up @@ -1392,7 +1392,7 @@

1.0.4-5 | 2017-09-14 18:56:16 -0500

* Require extra configparser package only for Python < 3.5
* Require extra configparser package only for Python < 3.5
where it is not included (Hilko Bengen)

* Fix imports for python3 (Robert Haist)
Expand Down
78 changes: 43 additions & 35 deletions doc/conf.py
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Zeek Package Manager documentation build configuration file, created by
# sphinx-quickstart on Fri Jul 15 13:46:04 2016.
Expand All @@ -18,8 +17,9 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath('./ext'))

sys.path.insert(0, os.path.abspath(".."))
sys.path.insert(0, os.path.abspath("./ext"))

# -- General configuration ------------------------------------------------

Expand All @@ -30,35 +30,35 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinxarg.ext', 'sphinx.ext.autodoc', 'sphinx.ext.napoleon']
extensions = ["sphinxarg.ext", "sphinx.ext.autodoc", "sphinx.ext.napoleon"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The encoding of source files.
#
# source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = u'Zeek Package Manager'
copyright = u'2019, The Zeek Project'
author = u'The Zeek Project'
project = "Zeek Package Manager"
copyright = "2019, The Zeek Project"
author = "The Zeek Project"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
with open('../VERSION', 'r') as f:
with open("../VERSION") as f:
version = f.readline().strip()

# The full version, including alpha/beta/rc tags.
Expand All @@ -83,7 +83,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# The reST default role (used for this markup: `text`) to use for all
# documents.
Expand All @@ -105,7 +105,7 @@
# show_authors = False

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
Expand All @@ -119,23 +119,24 @@

# -- Options for HTML output ----------------------------------------------

on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
on_rtd = os.environ.get("READTHEDOCS", None) == "True"

if not on_rtd:
# only import and set the theme if we're building docs locally
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'

html_theme = "sphinx_rtd_theme"

Check notice

Code scanning / CodeQL

Unused global variable

The global variable 'html_theme' is not used.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Sphinx seems to use magic variables, I am unsure what pattern to use to suppress this warning. Might be worthwhile just manually dismissing this whenever we make an edit to this file. That way we'd still get CodeQL analysis everywhere else (where we are unlikely to use such weird patterns).

html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

html_theme_options = {
'collapse_navigation': False,
'display_version': True,
"collapse_navigation": False,
"display_version": True,
}

# The name for this set of Sphinx documents.
# "<project> v<release> documentation" by default.
#
html_title = u'Zeek Package Manager Documentation'
html_title = "Zeek Package Manager Documentation"

# A shorter title for the navigation bar. Default is the same as html_title.
#
Expand All @@ -155,11 +156,13 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]


def setup(app):
#app.add_javascript("custom.js")
app.add_css_file("theme_overrides.css")
# app.add_javascript("custom.js")
app.add_css_file("theme_overrides.css")


# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
Expand All @@ -180,7 +183,7 @@ def setup(app):

# Custom sidebar templates, maps document names to template names.
#
#html_sidebars = {'**': ['custom-sidebar.html']}
# html_sidebars = {'**': ['custom-sidebar.html']}

# Additional templates that should be rendered to pages, maps page names to
# template names.
Expand Down Expand Up @@ -239,23 +242,20 @@ def setup(app):
# html_search_scorer = 'scorer.js'

# Output file base name for HTML help builder.
htmlhelp_basename = 'ZeekPackageManagerdoc'
htmlhelp_basename = "ZeekPackageManagerdoc"

# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -265,8 +265,13 @@ def setup(app):
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'ZeekPackageManager.tex', u'Zeek Package Manager Documentation',
u'The Zeek Project', 'manual'),
(
master_doc,
"ZeekPackageManager.tex",
"Zeek Package Manager Documentation",
"The Zeek Project",
"manual",
),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -306,10 +311,7 @@ def setup(app):

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('zkg', 'zkg', u'Zeek Package Manager',
[author], 1)
]
man_pages = [("zkg", "zkg", "Zeek Package Manager", [author], 1)]

# If true, show URL addresses after external links.
#
Expand All @@ -322,9 +324,15 @@ def setup(app):
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'ZeekPackageManager', u'Zeek Package Manager Documentation',
author, 'ZeekPackageManager', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"ZeekPackageManager",
"Zeek Package Manager Documentation",
author,
"ZeekPackageManager",
"One line description of project.",
"Miscellaneous",
),
]

# Documents to append as an appendix to all manuals.
Expand Down
2 changes: 1 addition & 1 deletion doc/zkg.rst
Expand Up @@ -50,7 +50,7 @@ remove
.. note::

You may also say ``uninstall``.

.. _purge-command:

purge
Expand Down
50 changes: 30 additions & 20 deletions setup.py
@@ -1,28 +1,38 @@
import pathlib
from setuptools import setup

install_requires = ['gitpython', 'semantic_version', 'btest']
install_requires = ["gitpython", "semantic_version", "btest"]


def version():
return pathlib.Path("VERSION").read_text().replace("-", ".dev", 1).strip()


def long_description():
return pathlib.Path("README").read_text()


setup(
name='zkg',
version=open('VERSION').read().replace('-', '.dev', 1).strip(),
description='The Zeek Package Manager',
long_description=open('README').read(),
license='University of Illinois/NCSA Open Source License',
keywords='zeek zeekctl zeekcontrol package manager scripts plugins security',
maintainer='The Zeek Project',
maintainer_email='info@zeek.org',
url='https://github.com/zeek/package-manager',
scripts=['zkg'],
packages=['zeekpkg'],
name="zkg",
version=version(),
bbannier marked this conversation as resolved.
Show resolved Hide resolved
description="The Zeek Package Manager",
long_description=long_description(),
license="University of Illinois/NCSA Open Source License",
keywords="zeek zeekctl zeekcontrol package manager scripts plugins security",
maintainer="The Zeek Project",
maintainer_email="info@zeek.org",
url="https://github.com/zeek/package-manager",
scripts=["zkg"],
packages=["zeekpkg"],
install_requires=install_requires,
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'License :: OSI Approved :: University of Illinois/NCSA Open Source License',
'Operating System :: POSIX :: Linux',
'Operating System :: MacOS :: MacOS X',
'Programming Language :: Python :: 3',
'Topic :: System :: Networking :: Monitoring',
'Topic :: Utilities',
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"License :: OSI Approved :: University of Illinois/NCSA Open Source License",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
"Programming Language :: Python :: 3",
"Topic :: System :: Networking :: Monitoring",
"Topic :: Utilities",
],
)
Expand Up @@ -2,7 +2,7 @@
#
# This is loaded when a user activates the plugin. Include scripts here that should be
# loaded automatically at that point.
#
#



Expand Down
Expand Up @@ -2,7 +2,7 @@
#
# This is loaded when a user activates the plugin. Include scripts here that should be
# loaded automatically at that point.
#
#



Expand Down
2 changes: 1 addition & 1 deletion testing/packages/rot13/scripts/Demo/Rot13/__load__.zeek
@@ -1,7 +1,7 @@
#
# This is loaded when a user activates the plugin. Include scripts here that should be
# loaded automatically at that point.
#
#



Expand Down
2 changes: 1 addition & 1 deletion testing/packages/rot13/scripts/__load__.zeek
@@ -1,7 +1,7 @@
#
# This is loaded unconditionally at Zeek startup. Include scripts here that should
# always be loaded.
#
#
# Normally, that will be only code that initializes built-in elements. Load
# your standard scripts in
# scripts/<plugin-namespace>/<plugin-name>/__load__.zeek instead.
Expand Down
10 changes: 4 additions & 6 deletions testing/packages/rot13/scripts/__preload__.zeek
@@ -1,12 +1,10 @@
#
# This is loaded unconditionally at Zeek startup before any of the BiFs that the
# plugin defines become available.
#
# plugin defines become available.
#
# This is primarily for defining types that BiFs already depend on. If you need
# to do any other unconditional initialization (usually that's just for other BiF
# elemets), that should go into __load__.zeek instead.
#
# elemets), that should go into __load__.zeek instead.
#

@load ./types.zeek


1 change: 0 additions & 1 deletion testing/packages/rot13/scripts/types.zeek
@@ -1 +0,0 @@

1 change: 0 additions & 1 deletion testing/packages/rot13/testing/tests/main
@@ -1,3 +1,2 @@
# @TEST-EXEC: zeek rot13 > output
# @TEST-EXEC: TEST_DIFF_CANONIFIER="sort -s" btest-diff output

1 change: 0 additions & 1 deletion testing/scripts/setup-zeek-and-home
Expand Up @@ -20,4 +20,3 @@ state_dir = ${zeek_zkg_state_dir}
script_dir = ${zeek_site_dir}
plugin_dir = ${zeek_plugins_dir}
" >> ${zeek_zkg_config_dir}/config