diff --git a/.github/workflows/automaticRelease.yaml b/.github/workflows/automaticRelease.yaml
index 64f94a7f..7ab9f930 100644
--- a/.github/workflows/automaticRelease.yaml
+++ b/.github/workflows/automaticRelease.yaml
@@ -25,14 +25,14 @@ jobs:
git commit -m "Update translations" --allow-empty
git pull
git push
-
- zip-rules:
+
+ zip-rules:
name: zip up the rules directory
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- - name: Build Rust Library
+ - name: Build Rust Library
run: |
cargo build --target x86_64-unknown-linux-gnu # doesn't need a release build since all that we want is the Rules dir
- name: create rules.zip
@@ -42,7 +42,7 @@ jobs:
filename: 'Rules.zip'
directory: 'addon/globalPlugins/MathCAT'
path: 'Rules'
- - name: Upload Rules.zip
+ - name: Upload Rules.zip
uses: actions/upload-artifact@v4
with:
name: 'Rules.zip'
@@ -50,7 +50,7 @@ jobs:
compression-level: 0
retention-days: 1
- rust-32:
+ rust-32:
name: Build 32 bit windows pyd file
runs-on: windows-latest # needs to run on windows because of bzip2
steps:
@@ -61,7 +61,7 @@ jobs:
with:
python-version: 3.11
architecture: 'x86'
- - name: Build Rust Library
+ - name: Build Rust Library
run: |
cargo build --target i686-pc-windows-msvc --release
- name: Setup Example dir
@@ -79,15 +79,15 @@ jobs:
filename: '../libmathcat_py-32-3.11-win.zip'
directory: 'Example'
path: 'libmathcat_py.pyd'
- - name: Upload 32 bit pyd file
+ - name: Upload 32 bit pyd file
uses: actions/upload-artifact@v4
with:
name: libmathcat_py-32-3.11-win.zip
path: libmathcat_py-32-3.11-win.zip
compression-level: 0
retention-days: 1
-
- rust-64:
+
+ rust-64:
name: Build 64 bit windows pyd file
runs-on: windows-latest # needs to run on windows because of bzip2
steps:
@@ -98,7 +98,7 @@ jobs:
with:
python-version: 3.11
architecture: 'x64'
- - name: Build Rust Library
+ - name: Build Rust Library
run: |
cargo build --target x86_64-pc-windows-msvc --release
- name: Setup Example dir
@@ -116,15 +116,15 @@ jobs:
run: |
cd Example
python test.py
- - name: Upload 64 bit pyd file
+ - name: Upload 64 bit pyd file
uses: actions/upload-artifact@v4
with:
name: libmathcat_py-64-3.11-win.zip
path: libmathcat_py-64-3.11-win.zip
compression-level: 0
retention-days: 1
-
- linux-64:
+
+ linux-64:
name: Build linux pyd file (64-bit intel)
runs-on: ubuntu-latest
steps:
@@ -135,7 +135,7 @@ jobs:
with:
python-version: 3.11
architecture: 'x64'
- - name: Build Rust Library
+ - name: Build Rust Library
run: |
cargo build --target x86_64-unknown-linux-gnu --release
- name: Setup Example dir
@@ -154,14 +154,14 @@ jobs:
filename: '../libmathcat_py-64-3.11-linux.zip'
directory: 'Example'
path: 'libmathcat_py.so'
- - name: Upload 64 bit pyd file
+ - name: Upload 64 bit pyd file
uses: actions/upload-artifact@v4
with:
name: libmathcat_py-64-3.11-linux.zip
path: libmathcat_py-64-3.11-linux.zip
compression-level: 0
retention-days: 1
-
+
build-addon:
name: build-addon
continue-on-error: false
@@ -202,7 +202,7 @@ jobs:
- name: Run scons to build .addon file
run: |
scons
- - name: Upload the addon
+ - name: Upload the addon
uses: actions/upload-artifact@v4
with:
name: addon
@@ -210,7 +210,7 @@ jobs:
compression-level: 0
retention-days: 1
- pre-release:
+ pre-release:
name: Pre Release
continue-on-error: false
needs: [zip-rules, rust-32, rust-64, linux-64, build-addon]
diff --git a/.github/workflows/checkTranslatorsComments.yml b/.github/workflows/checkTranslatorsComments.yaml
similarity index 97%
rename from .github/workflows/checkTranslatorsComments.yml
rename to .github/workflows/checkTranslatorsComments.yaml
index a8598c5c..8cbe7aac 100644
--- a/.github/workflows/checkTranslatorsComments.yml
+++ b/.github/workflows/checkTranslatorsComments.yaml
@@ -29,7 +29,7 @@ jobs:
pip install scons markdown
sudo apt update
sudo apt install gettext
-
+
- name: Generate the .pot file
run: scons pot
@@ -43,7 +43,7 @@ jobs:
# checkPot.EXPECTED_MESSAGES_WITHOUT_COMMENTS = set()
# res = checkPot.checkPot('$(ls *.pot)')
# exit(res)
- #shell: python
+ #shell: python
run: |
python -c "import checkPot;checkPot.EXPECTED_MESSAGES_WITHOUT_COMMENTS = set();exit(checkPot.checkPot('$(ls *.pot)'))"
echo "nb_errors=$?" >> "$GITHUB_OUTPUT"
@@ -58,4 +58,3 @@ jobs:
echo "Translators comments: FAIL"
exit 1;
fi
-
\ No newline at end of file
diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml
deleted file mode 100644
index db3c66cb..00000000
--- a/.github/workflows/lint.yaml
+++ /dev/null
@@ -1,36 +0,0 @@
-name: Lint
-
-on:
- push:
- branches:
- - main
- pull_request:
- branches:
- - main
-
-jobs:
-
- lint:
- runs-on: windows-latest
-
- steps:
- - name: Checkout code
- uses: actions/checkout@v3
- with:
- path: code
- - name: Set up Python 3.11
- uses: actions/setup-python@v4
- with:
- python-version: 3.11
- - name: debugging
- run: dir -l code
- - name: Install dependencies (flake8)
- run: pip install -r code/.github/workflows/requirements.txt
- - name: Lint
- run: flake8 code/addon --max-line-length=130 --extend-exclude=code/addon/globalPlugins/MathCAT/yaml/*
- - name: type check
- uses: jakebailey/pyright-action@v1
- with:
- working-directory: code/addon/globalPlugins/MathCAT
- python-version: 3.11
- pylance-version: latest-release
\ No newline at end of file
diff --git a/.github/workflows/manualRelease.yaml b/.github/workflows/manualRelease.yaml
index 54dcf356..21952ea4 100644
--- a/.github/workflows/manualRelease.yaml
+++ b/.github/workflows/manualRelease.yaml
@@ -3,7 +3,7 @@ name: Manual release
on:
workflow_dispatch:
inputs:
- version:
+ version:
description: 'Add-on version'
required: true
default: '0.0.0'
@@ -20,7 +20,7 @@ jobs:
buildAndUpload:
continue-on-error: true
runs-on: ubuntu-latest
-
+
permissions:
contents: write
@@ -50,7 +50,7 @@ jobs:
f.seek(0)
f.write(text)
f.truncate()
- shell: python
+ shell: python
- name: Build add-on
run: scons
- name: Push changes
@@ -67,7 +67,7 @@ jobs:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
- if: ${{ inputs.signAddOn }}
- name: Sign add-on
+ name: Sign add-on
run: gpg --detach-sign *.nvda-addon
- name: Calculate sha256
run: sha256sum *.nvda-addon >> sha256.txt
@@ -82,4 +82,3 @@ jobs:
artifacts: "*.nvda-addon,*.sig,publicKey.asc,sha256.txt"
generateReleaseNotes: true
prerelease: ${{ inputs.prerelease }}
-
diff --git a/.github/workflows/requirements.txt b/.github/workflows/requirements.txt
deleted file mode 100644
index 79ef110f..00000000
--- a/.github/workflows/requirements.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-####### requirements.txt #######
-#
-###### Requirements for automated lint ######
-flake8 >= 3.8
-flake8-tabs >= 2.3
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 0be8af1c..51f2b434 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,4 @@ manifest.ini
*.nvda-addon
.sconsign.dblite
/[0-9]*.[0-9]*.[0-9]*.json
+.venv/
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 00000000..d5c872f7
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,96 @@
+
+# https://pre-commit.ci/
+# Configuration for Continuous Integration service
+ci:
+ skip: [pyrightLocal]
+ autoupdate_schedule: monthly
+ autoupdate_commit_msg: "Pre-commit auto-update"
+ autofix_commit_msg: "Pre-commit auto-fix"
+ submodules: true
+
+default_language_version:
+ python: python3.11
+
+repos:
+- repo: https://github.com/pre-commit-ci/pre-commit-ci-config
+ rev: v1.6.1
+ hooks:
+ - id: check-pre-commit-ci-config
+
+- repo: meta
+ hooks:
+ # ensures that exclude directives apply to any file in the repository.
+ - id: check-useless-excludes
+ # ensures that the configured hooks apply to at least one file in the repository.
+ - id: check-hooks-apply
+
+- repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: v5.0.0
+ hooks:
+ # Prevents commits to certain branches
+ - id: no-commit-to-branch
+ args: ["--branch", "main"]
+ # Checks that large files have not been added. Default cut-off for "large" files is 500kb.
+ - id: check-added-large-files
+ # Checks python syntax
+ - id: check-ast
+ # Checks for filenames that will conflict on case insensitive filesystems (the majority of Windows filesystems, most of the time)
+ - id: check-case-conflict
+ # Checks for artifacts from resolving merge conflicts.
+ - id: check-merge-conflict
+ # Checks Python files for debug statements, such as python's breakpoint function, or those inserted by some IDEs.
+ - id: debug-statements
+ # Removes trailing whitespace.
+ - id: trailing-whitespace
+ types_or: [python, batch, markdown, toml, yaml, rust]
+ # Ensures all files end in 1 (and only 1) newline.
+ - id: end-of-file-fixer
+ types_or: [python, batch, markdown, toml, yaml, rust]
+ # Removes the UTF-8 BOM from files that have it.
+ # See https://github.com/nvaccess/nvda/blob/master/projectDocs/dev/codingStandards.md#encoding
+ - id: fix-byte-order-marker
+ types_or: [python, batch, markdown, toml, yaml, rust]
+ # Validates TOML files.
+ - id: check-toml
+ # Validates YAML files.
+ - id: check-yaml
+ # Validates XML files.
+ # Ensures that links to lines in files under version control point to a particular commit.
+ - id: check-vcs-permalinks
+ # Avoids using reserved Windows filenames.
+ - id: check-illegal-windows-names
+
+- repo: https://github.com/asottile/add-trailing-comma
+ rev: v3.1.0
+ hooks:
+ # Ruff preserves indent/new-line formatting of function arguments, list items, and similar iterables,
+ # if a trailing comma is added.
+ # This adds a trailing comma to args/iterable items in case it was missed.
+ - id: add-trailing-comma
+
+- repo: https://github.com/astral-sh/ruff-pre-commit
+ # Matches Ruff version in pyproject.
+ rev: v0.8.1
+ hooks:
+ - id: ruff
+ name: lint with ruff
+ args: [ --fix ]
+ - id: ruff-format
+ name: format with ruff
+
+- repo: https://github.com/RobertCraigie/pyright-python
+ rev: v1.1.394
+ hooks:
+ - id: pyright
+ alias: pyrightLocal
+ name: Check types with pyright
+
+- repo: https://github.com/RobertCraigie/pyright-python
+ rev: v1.1.396
+ hooks:
+ - id: pyright
+ alias: pyrightCI
+ name: Check types with pyright
+ # use nodejs version of pyright and install pyproject.toml for CI
+ additional_dependencies: [".", "pyright[nodejs]"]
+ stages: [manual] # Only run from CI manually
diff --git a/Cargo.toml b/Cargo.toml
index 2549373d..7b4eeed5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -31,7 +31,7 @@ version = "0.22"
features = ["extension-module", "abi3"]
[build-dependencies]
-zip = { version = "2.6", default-features = false, features = ["bzip2"] }
+zip = { version = "3.0", default-features = false, features = ["bzip2"] }
mathcat = {version = "=0.6.9", features = ["include-zip"]} # for building, we want the zip files so we can include them separately
# mathcat = { path = "../MathCAT/", features = ["include-zip"]} # for building, we want the zip files so we can include them separately
# for testing MathCAT without having to publish a new version (change two occurrences)
diff --git a/Example/test.py b/Example/test.py
index 37038ac5..579d0c79 100644
--- a/Example/test.py
+++ b/Example/test.py
@@ -8,7 +8,7 @@
import os
import sys
-import libmathcat_py as libmathcat # type: ignore
+import libmathcat_py as libmathcat
# import shutil
# if os.path.exists("libmathcat_py.pyd"):
@@ -17,91 +17,91 @@
def setMathCATPreferences():
- try:
- libmathcat.SetRulesDir(
- # this assumes the Rules dir is in the same dir a the library. Modify as needed
- os.path.join(os.path.dirname(os.path.abspath(__file__)), "Rules")
- )
- except Exception as e:
- sys.exit(f"problem with finding the MathCAT rules: {e}")
-
- try:
- libmathcat.SetPreference("TTS", "none")
- libmathcat.SetPreference("Language", "en") # Also "id" and "vi"
- libmathcat.SetPreference("SpeechStyle", "SimpleSpeak") # Also "ClearSpeak"
- libmathcat.SetPreference("Verbosity", "Verbose") # also terse "Terse"/"Medium"
- libmathcat.SetPreference("CapitalLetters_UseWord", "true") # if "true", X => "cap x"
- libmathcat.SetPreference("BrailleCode", "Nemeth")
- except Exception as e:
- sys.exit(f"problem with setting a preference: {e}")
+ try:
+ libmathcat.SetRulesDir(
+ # this assumes the Rules dir is in the same dir a the library. Modify as needed
+ os.path.join(os.path.dirname(os.path.abspath(__file__)), "Rules"),
+ )
+ except Exception as e:
+ sys.exit(f"problem with finding the MathCAT rules: {e}")
+
+ try:
+ libmathcat.SetPreference("TTS", "none")
+ libmathcat.SetPreference("Language", "en") # Also "id" and "vi"
+ libmathcat.SetPreference("SpeechStyle", "SimpleSpeak") # Also "ClearSpeak"
+ libmathcat.SetPreference("Verbosity", "Verbose") # also terse "Terse"/"Medium"
+ libmathcat.SetPreference("CapitalLetters_UseWord", "true") # if "true", X => "cap x"
+ libmathcat.SetPreference("BrailleCode", "Nemeth")
+ except Exception as e:
+ sys.exit(f"problem with setting a preference: {e}")
def setMathMLForMathCAT(mathml: str):
- try:
- libmathcat.SetMathML(mathml)
- except Exception as e:
- sys.exit(f"problem with setMathML: {e}")
+ try:
+ libmathcat.SetMathML(mathml)
+ except Exception as e:
+ sys.exit(f"problem with setMathML: {e}")
def getSpeech():
- try:
- return libmathcat.GetSpokenText()
- except Exception as e:
- sys.exit(f"problem with getting speech for MathML: {e}")
+ try:
+ return libmathcat.GetSpokenText()
+ except Exception as e:
+ sys.exit(f"problem with getting speech for MathML: {e}")
def getBraille():
- try:
- return libmathcat.GetBraille("")
- except Exception as e:
- sys.exit(f"problem with getting braille for MathML: {e}")
+ try:
+ return libmathcat.GetBraille("")
+ except Exception as e:
+ sys.exit(f"problem with getting braille for MathML: {e}")
def test():
- setMathCATPreferences() # you only need to this once
- print("Using MathCAT version '{}'".format(libmathcat.GetVersion()))
-
- mathml = ""
- setMathMLForMathCAT(mathml)
- speech = getSpeech()
- if speech != '1 over cap x':
- sys.exit(f"MathML: {mathml}\nSpeech: '{speech}'")
- braille = getBraille()
- if braille != '⠹⠂⠌⠠⠭⠼':
- sys.exit(f"MathML: {mathml}\nBraille: '{braille}'")
-
- mathml = ""
- setMathMLForMathCAT(mathml)
- speech = getSpeech()
- if speech != 'x cross product y':
- sys.exit(f"MathML: {mathml}\nSpeech: '{speech}'")
-
- mathml = ""
- setMathMLForMathCAT(mathml)
- speech = getSpeech()
- if speech != 'x cubed':
- sys.exit(f"MathML: {mathml}\nSpeech: '{speech}'")
-
- mathml = ""
- setMathMLForMathCAT(mathml)
- speech = getSpeech()
- if speech != 'x transpose':
- sys.exit(f"MathML: {mathml}\nSpeech: '{speech}'")
-
- mathml = ""
- setMathMLForMathCAT(mathml)
- speech = getSpeech()
- if speech != 'x factorial':
- sys.exit(f"MathML: {mathml}\nSpeech: '{speech}'")
-
- mathml = "