Merge pull request #1 from alexwlchan/github-actions
- ID
771d332- date
2024-05-19 20:50:59+00:00- author
Alex Chan <alex@alexwlchan.net>- parents
9f5c3d8,c173496- message
Merge pull request #1 from alexwlchan/github-actions Add some basic GitHub Actions and Dependabot config- changed files
7 files, 118 additions, 9 deletions
Changed files
.github/dependabot.yml (0) → .github/dependabot.yml (203)
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000..47a31bc
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,10 @@
+version: 2
+updates:
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "daily"
+ - package-ecosystem: "pip"
+ directory: "/"
+ schedule:
+ interval: "daily"
.github/workflows/test.yml (0) → .github/workflows/test.yml (1231)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..2dddad5
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,47 @@
+name: Test
+
+on:
+ push:
+ branches:
+ - main
+
+ pull_request:
+ branches:
+ - main
+
+jobs:
+ test:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Set up Python
+ uses: actions/setup-python@v5
+ with:
+ python-version: 3.12
+ cache: pip
+ cache_path: dev_requirements.txt
+
+ - name: Install dependencies
+ run: pip install -r dev_requirements.txt
+
+ - name: Run linting
+ run: |
+ black --check .
+
+ # E501 = line too long; anything up to 100-ish is fine in my book
+ # (the "ish" is intentional; see https://www.youtube.com/watch?v=wf-BqAjZb8M)
+ #
+ # E203/W503/W504 = this is where black and flake8 conflict, see https://black.readthedocs.io/en/stable/faq.html#why-are-flake8-s-e203-and-w503-violated
+ #
+ # F821 = undefined name, which I need because there are bits in my
+ # Python expansions that are used by Alfred and which Python doesn't
+ # know what to do with, imports I expect will be elsewhere, etc.
+ flake8 --ignore=E501,E203,W503,F821 --extend-select=W504
+
+ - name: Check types
+ run: mypy *.py
+
+ - name: Build the workflow
+ run: python3 create_snippets.py
README.md (1592) → README.md (1644)
diff --git a/README.md b/README.md
index f7376b6..3be86e5 100644
--- a/README.md
+++ b/README.md
@@ -29,4 +29,4 @@ I configure those in the in-app editor, because I don't want to put them in a pu
$ python3 create_snippets.py
```
-This will open the newly-created snippets collection in Alfred Preferences.
+This will create a new file `Alex’s snippets.alfredsnippets`, which you can open to add these snippets to Alfred Preferences.
create_snippets.py (7434) → create_snippets.py (7361)
diff --git a/create_snippets.py b/create_snippets.py
index 91096ad..7dd1338 100755
--- a/create_snippets.py
+++ b/create_snippets.py
@@ -4,13 +4,12 @@ import hashlib
import json
import os
import pathlib
-import subprocess
import uuid
import zipfile
-def read(name):
- with open(os.path.join('expansions', name)) as infile:
+def read(name: str) -> str:
+ with open(os.path.join("expansions", name)) as infile:
return infile.read()
@@ -251,7 +250,7 @@ SNIPPETS = {
# fmt: on
-def add_snippet(zf: zipfile.ZipFile, shortcut: str, expansion: str):
+def add_snippet(zf: zipfile.ZipFile, shortcut: str, expansion: str) -> None:
"""
Add a single snippet to a snippets bundle.
"""
@@ -273,14 +272,11 @@ def add_snippet(zf: zipfile.ZipFile, shortcut: str, expansion: str):
zf.writestr(f"{snippet_id}.json", data=json.dumps(snippet_data))
-
if __name__ == "__main__":
curdir = pathlib.Path(os.getcwd()).absolute()
- with zipfile.ZipFile(f"Alex’s snippets.alfredsnippets", "w") as zf:
+ with zipfile.ZipFile("Alex’s snippets.alfredsnippets", "w") as zf:
zf.write("info.plist")
for shortcut, expansion in SNIPPETS.items():
add_snippet(zf, shortcut, expansion)
-
- subprocess.check_call(["open", "Alex’s snippets.alfredsnippets"])
dev_requirements.in (0) → dev_requirements.in (18)
diff --git a/dev_requirements.in b/dev_requirements.in
new file mode 100644
index 0000000..355ed83
--- /dev/null
+++ b/dev_requirements.in
@@ -0,0 +1,3 @@
+black
+flake8
+mypy
dev_requirements.txt (0) → dev_requirements.txt (604)
diff --git a/dev_requirements.txt b/dev_requirements.txt
new file mode 100644
index 0000000..e7a1e32
--- /dev/null
+++ b/dev_requirements.txt
@@ -0,0 +1,32 @@
+#
+# This file is autogenerated by pip-compile with Python 3.12
+# by the following command:
+#
+# pip-compile dev_requirements.in
+#
+black==24.4.2
+ # via -r dev_requirements.in
+click==8.1.7
+ # via black
+flake8==7.0.0
+ # via -r dev_requirements.in
+mccabe==0.7.0
+ # via flake8
+mypy==1.10.0
+ # via -r dev_requirements.in
+mypy-extensions==1.0.0
+ # via
+ # black
+ # mypy
+packaging==24.0
+ # via black
+pathspec==0.12.1
+ # via black
+platformdirs==4.2.2
+ # via black
+pycodestyle==2.11.1
+ # via flake8
+pyflakes==3.2.0
+ # via flake8
+typing-extensions==4.11.0
+ # via mypy
pyproject.toml (0) → pyproject.toml (497)
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..38d30dd
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,21 @@
+[project]
+name = "snipperts"
+version = "1.0"
+
+[tool.mypy]
+mypy_path = "src"
+check_untyped_defs = true
+disallow_any_generics = true
+disallow_incomplete_defs = true
+disallow_subclassing_any = true
+disallow_untyped_calls = true
+disallow_untyped_decorators = true
+disallow_untyped_defs = true
+no_implicit_optional = true
+no_implicit_reexport = true
+show_error_codes = true
+strict_equality = true
+warn_redundant_casts = true
+warn_return_any = true
+warn_unused_configs = true
+warn_unused_ignores = true