Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/topic/bbannier/pre-commit'
Browse files Browse the repository at this point in the history
* origin/topic/bbannier/pre-commit:
  Replace manual nested loops with set operation.
  Make sure files are properly closed in `setup.py`.
  Automatically update Python sources to use python-3.7 syntax.
  Add `.git-blame-ignore-revs` file.
  Reformat Python code with Black.
  Add GH action to run pre-commit.
  Add pre-commit config.
  • Loading branch information
ckreibich committed Jan 10, 2023
2 parents 0cbbb34 + 90a80b4 commit b218122
Show file tree
Hide file tree
Showing 31 changed files with 2,498 additions and 1,837 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Migrate code style to Black
99520f9201340d57d2cc9cf6f45992b994eff7c4
16 changes: 16 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: ["--py37-plus"]

exclude: doc/ext/sphinxarg
18 changes: 17 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
2.13.0-17 | 2023-01-10 12:54:54 -0800

* Replace manual nested loops with set operation. (Benjamin Bannier, Corelight)

* Make sure files are properly closed in `setup.py`. (Benjamin Bannier, Corelight)

* Automatically update Python sources to use python-3.7 syntax. (Benjamin Bannier, Corelight)

* Add `.git-blame-ignore-revs` file. (Benjamin Bannier, Corelight)

* Reformat Python code with Black. (Benjamin Bannier, Corelight)

* Add GH action to run pre-commit. (Benjamin Bannier, Corelight)

* Add pre-commit config. (Benjamin Bannier, Corelight)

2.13.0-9 | 2023-01-05 13:17:20 -0800

* Tweaks to appease CodeQL (Christian Kreibich, Corelight)
Expand Down Expand Up @@ -1392,7 +1408,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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.13.0-9
2.13.0-17
78 changes: 43 additions & 35 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -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"
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
Loading

0 comments on commit b218122

Please sign in to comment.