From 403e466f8583fb160a94c30261119ab22027d81b Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 4 May 2026 11:46:46 -0400 Subject: [PATCH] Mostly administative stuff location.py: guard against no filename (happens in an interactive session) Add YAML lint checking, especially for GitHub CI work YAML. --- .pre-commit-config.yaml | 11 ++++++++--- .yamllint | 4 ++++ mathics_scanner/location.py | 5 ++++- pyproject.toml | 3 ++- 4 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 .yamllint diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a2be9e22..401c293b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,8 @@ +--- default_language_version: python: python repos: -- repo: https://github.com/pre-commit/pre-commit-hooks + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 hooks: - id: check-merge-conflict @@ -15,16 +16,20 @@ repos: exclude: ChangeLog-spell-corrected.diff - id: check-json exclude: mathics_scanner/data/character-tables.json -- repo: https://github.com/pycqa/isort + - repo: https://github.com/pycqa/isort rev: 5.13.2 hooks: - id: isort stages: [pre-commit] args: ["--profile", "black"] -- repo: https://github.com/psf/black + - repo: https://github.com/psf/black rev: 25.11.0 hooks: - id: black language_version: python3 stages: [pre-commit] exclude: version.py + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.31.0 # Use the latest version + hooks: + - id: check-github-workflows diff --git a/.yamllint b/.yamllint new file mode 100644 index 00000000..1052c4f1 --- /dev/null +++ b/.yamllint @@ -0,0 +1,4 @@ +# -*- conf -*- +# .yamllint configuration file +rules: + line-length: disable diff --git a/mathics_scanner/location.py b/mathics_scanner/location.py index 1f309bb8..11536925 100644 --- a/mathics_scanner/location.py +++ b/mathics_scanner/location.py @@ -75,6 +75,9 @@ def get_location_file_line( filename = code.co_filename line_number = code.co_firstlineno else: - filename = MATHICS3_PATHS[loc.container] + try: + filename = MATHICS3_PATHS[loc.container] + except IndexError: + filename = "???" line_number = loc.start_line return filename, line_number diff --git a/pyproject.toml b/pyproject.toml index 0eec94d4..0d3bf7ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,6 @@ classifiers = [ "Intended Audience :: Developers", "Intended Audience :: Science/Research", "Programming Language :: Python", - "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", @@ -45,6 +44,8 @@ Homepage = "https://mathics.org/" [project.optional-dependencies] dev = [ + "check-jsonschema", + "pre-commit", "pytest", ] full = [