Skip to content
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
23 changes: 0 additions & 23 deletions .coveragerc

This file was deleted.

19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.{yml,yaml,toml,json}]
indent_size = 2

[*.md]
# Trailing whitespace is significant in Markdown, and README.md is generated.
trim_trailing_whitespace = false

[Makefile]
indent_style = tab
31 changes: 12 additions & 19 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
# Auto detect text files and perform LF normalization
# Normalise line endings in the repository, checking out the platform native
# ones. This is what keeps the tree consistent between Windows and Linux.
* text=auto

# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
*.py text diff=python
*.md text
*.toml text
*.yml text
*.yaml text
*.txt text
Makefile text

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
# Generated from the directkeys module docstring by the `build` target, so it
# should not count towards language statistics or clutter pull request diffs.
README.md linguist-generated=true
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
commit-message:
prefix: "ci"

- package-ecosystem: pip
directory: /
schedule:
interval: monthly
commit-message:
prefix: "build"
29 changes: 20 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ on:
workflow_dispatch:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: '3.13'

- uses: astral-sh/ruff-action@v3

- name: Lint
run: ruff check --output-format=github .

- name: Check formatting
run: ruff format --check .

test:
runs-on: ${{ matrix.os }}
strategy:
Expand All @@ -15,14 +32,7 @@ jobs:
# The Linux backend only touches /dev/input from init(), so the suite
# imports and runs unprivileged against the fake backend, as on Windows.
os: [windows-latest, ubuntu-latest]
python-version: ['3.11', '3.13']
include:
# ubuntu-latest no longer ships 3.8, the oldest version claimed by
# requires-python, so pin the older runner for that one job.
- os: ubuntu-22.04
python-version: '3.8'
- os: windows-latest
python-version: '3.8'
python-version: ['3.9', '3.11', '3.13']

steps:
- uses: actions/checkout@v4
Expand All @@ -38,7 +48,8 @@ jobs:
pip install -e .

- name: Run tests
run: python -m pytest tests/ -v --ignore=tests/manual
# testpaths and norecursedirs come from pyproject.toml.
run: python -m pytest -v

build:
runs-on: ubuntu-latest
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ eggs/
htmlcov/
coverage_html_report/

# Tooling caches
.ruff_cache/
.mypy_cache/

# Editor and OS specific files
.vscode/
.idea/
Expand All @@ -36,4 +40,4 @@ Desktop.ini
*.bak
*.tmp
*.swp
*~.nib
*~.nib
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.16.1
hooks:
- id: ruff-check
args: [--fix]
- id: ruff-format

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
# README.md is generated from the __init__ docstring; leave it alone.
exclude: ^README\.md$
- id: end-of-file-fixer
exclude: ^README\.md$
- id: check-yaml
- id: check-toml
- id: check-merge-conflict
- id: check-added-large-files
26 changes: 24 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,32 @@ New features:
- `KeyboardEvent.flags` exposes the low-level hook flags, and is included in
`to_json()`. On Windows it currently carries the `LLKHF_EXTENDED` bit.

Packaging:
Also exposes `__version__` as the canonical version attribute. The upstream
`version` name is kept as an alias, so nothing breaks.

Packaging and project layout:

- Renamed the package and the distribution to `directkeys`.
- Metadata moved to `pyproject.toml`; Python 3.8+ is required.
- **Python 3.9+ is now required.** 3.8 reached end of life in October 2024.
All the Python 2 compatibility shims are gone with it.
- Metadata moved to `pyproject.toml`; `setup.py` is now only a shim.
- The package moved to a `src/` layout, so the test run exercises the
installed distribution rather than the source tree.
- Ruff (lint and format), pre-commit and an EditorConfig are configured, and
CI runs the suite plus a lint and a build check on Windows and Linux.

Fixes carried over from the initial fork work:

- `force_reset_keyboard()`, `get_stuck_keys()` and `reset_internal_state()`
were never loaded from the Windows backend and always resolved to no-op
stubs.
- `get_modifiers()` built a 32772-element tuple on every keystroke whenever
shift was held, because `GetKeyState` reports the pressed bit as `0x8000`.
- `set_alt_gr_abstraction()` never rebuilt the name tables.
- Key events reported `is_keypad` as the extended-key flag, which is close to
the inverse of the intended value, and dropped the `scan_code or -vk`
fallback for keys with no scan code.
- Importing the package on macOS no longer fails when pyobjc is missing.


# 0.13.5
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include CHANGES.md
include README.md
include LICENSE.txt
include pyproject.toml
include pyproject.toml
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
test:
python -m pytest tests/ --cov=directkeys --cov-report=html
python -m pytest --cov=directkeys --cov-report=html

build: tests directkeys pyproject.toml README.md CHANGES.md MANIFEST.in
lint:
python -m ruff check .
python -m ruff format --check .

format:
python -m ruff check --fix .
python -m ruff format .

build: tests src/directkeys pyproject.toml README.md CHANGES.md MANIFEST.in
python ../docstring2markdown/docstring2markdown.py directkeys "https://github.com/WigoWigo10/keyboard/blob/master" > README.md
find . \( -name "*.py" -o -name "*.sh" -o -name "* .md" \) -exec dos2unix {} \;
python -m build && twine check dist/*
Expand All @@ -10,4 +18,4 @@ release:
python make_release.py

clean:
rm -rfv dist build coverage_html_report directkeys.egg-info
rm -rfv dist build coverage_html_report directkeys.egg-info
24 changes: 23 additions & 1 deletion README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading