Skip to content

Commit

Permalink
Sort repos of a given type when adding a repo to that type (#35)
Browse files Browse the repository at this point in the history
* Sort repos of a given type when adding a repo to that type

Also:

- Add pre-commit config and run against all files

* Include license content

* Reformat files

* Fix tests
  • Loading branch information
daneah authored Nov 14, 2024
1 parent 0696611 commit 55ae0bd
Show file tree
Hide file tree
Showing 16 changed files with 156 additions and 157 deletions.
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/code-issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
name: Code issue
about: Identify an issue with the source code
title: A concise summary of the issue should go here
labels: ''
assignees: ''

labels: ""
assignees: ""
---

[Line(s) of code in question](<GitHub link to highlighted file lines>)
Expand Down
28 changes: 14 additions & 14 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: "CodeQL"

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]
schedule:
- cron: '37 17 * * 0'
- cron: "37 17 * * 0"

jobs:
analyze:
Expand All @@ -20,19 +20,19 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'python' ]
language: ["python"]

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Autobuild
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
56 changes: 56 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
####################################################
# Checks about the pre-commit configuration itself #
####################################################

repos:
- repo: meta
hooks:
- id: check-hooks-apply # Ensures all defined hooks affect at least one file in the repo
- id: check-useless-excludes # Ensures all defined excludes apply to at least one file in the repo

###########################
# General use / built-ins #
###########################

# Click through to this repository to see what other goodies are available
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-ast # Checks Python code for syntax errors
- id: trailing-whitespace # Removes trailing whitespace from lines in all file types
- id: end-of-file-fixer # Fixes last line of all file types
- id: check-merge-conflict # Checks if you're about to commit a file that hasn't had conflicts resolved
- id: no-commit-to-branch # Checks if you're committing to a disallowed branch (default is master)
- id: check-toml # Checks TOML files for syntax errors
- id: check-yaml # Checks YAML files for syntax errors
args: [--allow-multiple-documents]

##########
# Python #
##########

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.3
hooks:
- id: ruff

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
hooks:
- id: mypy
additional_dependencies: [typer, types-termcolor]

- repo: https://github.com/asottile/pyupgrade
rev: v3.19.0
hooks:
- id: pyupgrade
args: [--py39-plus]

############
# Markdown #
############

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier
6 changes: 4 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
**REPLACE THIS CONTENT WITH THE LICENSE LOCATED AT THE FOLLOWING URL**:
Copyright 2024 Dane Hillard

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

https://opensource.org/licenses/MIT
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Move from `setup.cfg` to `pyproject.toml` for package configuration
- Move from `black` to `ruff` for formatting
- Move from `isort` to `ruff` for import sorting
- Sort repos of a given type alphabetically when adding a repo to that type

## [0.0.11] - 2024-10-09

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Use alpha versioning during initial development such that all versions are monot

## Consequences

- Consumers won't know when a change is breaking, and should assume *every* change is breaking
- Consumers won't know when a change is breaking, and should assume _every_ change is breaking
- This decision will need to be amended once the project matures into a stable release pattern
- There is sometimes confusion about versions like `0.0.996` and people try to install `0.99.6` or similar instead
- Every released change during initial development will simply increase the last portion of the version string by one
60 changes: 33 additions & 27 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
import datetime
import os
from importlib import metadata
from typing import Any

from sphinx.application import Sphinx

# import sys
# sys.path.insert(0, os.path.abspath('.'))

Expand All @@ -21,9 +25,9 @@

CURRENT_YEAR = datetime.datetime.now().year

project = 'repo-man'
copyright = f'{CURRENT_YEAR}, Dane Hillard'
author = 'Dane Hillard'
project = "repo-man"
copyright = f"{CURRENT_YEAR}, Dane Hillard"
author = "Dane Hillard"
PACKAGE_VERSION = metadata.version("repo-man")
version = PACKAGE_VERSION
release = PACKAGE_VERSION
Expand All @@ -35,29 +39,28 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'myst_parser',
'sphinx.ext.intersphinx',
'sphinx.ext.autodoc',
'sphinx.ext.autodoc.typehints',
"myst_parser",
"sphinx.ext.intersphinx",
"sphinx.ext.autodoc",
"sphinx.ext.autodoc.typehints",
]

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

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
nitpick_ignore = [('py:class', 'typer.models.Context')]

exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
nitpick_ignore = [("py:class", "typer.models.Context")]


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

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'furo'
html_theme = "furo"

# 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,
Expand All @@ -83,19 +86,22 @@
PROJECT_ROOT = Path(__file__).parent.parent
PACKAGE_ROOT = PROJECT_ROOT / "src" / "repo_man"

def run_apidoc(_):
def run_apidoc(_: Any) -> None:
from sphinx.ext import apidoc
apidoc.main([
"--force",
"--implicit-namespaces",
"--module-first",
"--separate",
"-o",
str(PROJECT_ROOT / "docs" / "reference"),
str(PACKAGE_ROOT),
str(PACKAGE_ROOT / "*.c"),
str(PACKAGE_ROOT / "*.so"),
])

def setup(app):
app.connect('builder-inited', run_apidoc)

apidoc.main(
[
"--force",
"--implicit-namespaces",
"--module-first",
"--separate",
"-o",
str(PROJECT_ROOT / "docs" / "reference"),
str(PACKAGE_ROOT),
str(PACKAGE_ROOT / "*.c"),
str(PACKAGE_ROOT / "*.so"),
]
)

def setup(app: Sphinx) -> None:
app.connect("builder-inited", run_apidoc)
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,16 @@ commands = [
]

[tool.tox.env.typecheck]
extras = [
"docs",
]
deps = [
{ replace = "ref", of = ["tool", "tox", "env_run_base", "deps"], extend = true },
"mypy",
"types-termcolor",
]
commands = [
["mypy", { replace = "posargs", default = ["src", "test"], extend = true }],
["mypy", { replace = "posargs", default = ["src", "test", "docs"], extend = true }],
]

[tool.tox.env.format]
Expand All @@ -140,7 +143,7 @@ deps = [
"ruff",
]
commands = [
["ruff", "check", { replace = "posargs", default = ["src", "test"], extend = true }],
["ruff", "check", { replace = "posargs", default = ["src", "test", "docs"], extend = true }],
]

[tool.tox.env.docs]
Expand Down
3 changes: 2 additions & 1 deletion src/repo_man/commands/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def add(
config.add_section(repo_type)

if "known" not in config[repo_type] or str(repo) not in config[repo_type]["known"].split("\n"):
config.set(repo_type, "known", f"{original_config}\n{repo}")
ordered_repos = sorted(original_config.split("\n") + [str(repo)])
config.set(repo_type, "known", "\n".join(ordered_repos))

with open(REPO_TYPES_CFG, "w") as config_file:
config.write(config_file)
Loading

0 comments on commit 55ae0bd

Please sign in to comment.