Skip to content

Add codespell, consistent US english style & correct typos - #706

Closed
purva-thakre wants to merge 29 commits into
mainfrom
fix_typos
Closed

purva-thakre wants to merge 29 commits into
mainfrom
fix_typos

Conversation

@purva-thakre

@purva-thakre purva-thakre commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Description

https://github.com/codespell-project/codespell

This PR integrates codespell into the CI pipeline and fixes non-API British spellings found across the codebase. Public API names that use British spelling (e.g., Job.cancelled(), Jaspr.embedd()) are preserved via the ignore list or inline # codespell:ignore markers. The latter will be handled by separate PRs.

Configuration Changes

.github/workflows/lint.yml (renamed from ruff_checks.yml)

  • Added Codespell step to CI (runs on every PR/push to main)
  • Uses codespell with --builtin clear,rare,en-GB_to_en-US dictionaries
  • Runs alongside existing Ruff format check
  • On failure, emits warning annotations directing contributors to run codespell locally

pyproject.toml

  • Added [tool.codespell] section with:
    • builtin = "clear,rare,en-GB_to_en-US" — unambiguous errors, rare words, British→American
    • check-filenames = true — also checks file names
    • count = true and summary = true
    • Skip patterns for: .venv, .git, virtual envs, caches, binary files, generated doc build, pre-0.10 changelogs
    • ignore-words-list — false positives (ancilla, ket, Aer, MIS, proper names, etc.)
  • Added codespell<=2.4.2 to dev-code-style optional dependencies

Related Issues

Closes #
Related to #

Type of Change

  • Feature (new functionality)
  • Change Request (modification of existing functionality)
  • Bug Fix
  • Refactoring (no behavior change)
  • Performance improvement
  • Documentation
  • CI / Build

Breaking Change?

  • Yes
  • No

If yes, describe the impact and migration path:

What was changed?

How was it tested?

Test-ID Status
T-001 ✅ / ❌
T-002 ✅ / ❌
T-003 ✅ / ❌
T-004 ✅ / ❌

Screenshots / Output (if applicable)

Checklist

  • My code follows the project's coding standards
  • I have performed a self-review
  • I have added/updated tests (referencing issue Test-IDs)
  • All tests pass locally and in CI
  • I have updated the documentation
  • I have added a changelog entry
  • Breaking changes are documented with migration path

Reviewer Notes

@purva-thakre purva-thakre changed the title Add codespell, consistent english style Add codespell and consistent Am english style Jul 6, 2026
@purva-thakre purva-thakre changed the title Add codespell and consistent Am english style Add codespell, consistent Am english style & correct typos Jul 6, 2026
@purva-thakre
purva-thakre force-pushed the fix_typos branch 3 times, most recently from 0c0dec4 to 2bbe4a4 Compare July 6, 2026 11:09
@purva-thakre
purva-thakre marked this pull request as ready for review July 6, 2026 11:44
@purva-thakre

Copy link
Copy Markdown
Contributor Author

This PR is ready for a review. Note that the PR only makes non-breaking changes. There are spelling related public API changes that we should discuss before adding the respective PRs. Codespell flags them, but they are preserved in this branch (via ignore-words-list or inline # codespell:ignore markers) to avoid breaking changes.

1. Job.cancelled() / JobStatus.CANCELLED / JobCancelledError

  • File: src/qrisp/interface/job.py
  • Current: cancelled() method, CANCELLED enum value, JobCancelledError exception
  • Proposed: canceled(), CANCELED, JobCanceledError
  • Impact: Requires updating provider backends (aqt_backend.py, iqm_backend.py, qiskit_backend.py), all test files referencing the API, and documentation
  • Preserved by: cancelled in ignore-words-list

2. Jaspr.embedd()

  • File: src/qrisp/jasp/jasp_expression/centerclass.py
  • Current: def embedd(self, *args, name=None, inline=False)
  • Proposed: def embed(self, *args, name=None, inline=False)
  • Impact: Requires updating call sites in control_transform.py and any user code calling jaspr.embedd()
  • Preserved by: Inline # codespell:ignore marker

3. jasp_multiplyers module and functions

  • File: src/qrisp/alg_primitives/arithmetic/jasp_arithmetic/jasp_multiplyers.py
  • Current: Module jasp_multiplyers, functions jasp_multiplyer(), jasp_controlling_multiplyer()
  • Proposed: Module jasp_multipliers, functions jasp_multiplier(), jasp_controlling_multiplier()
  • Impact: Requires updating imports in __init__.py, quantum_float.py, test_qache.py, test_quantum_array.py, test_QAOAMkCS.py, test_QAOAQUBO.py — proceed with caution
  • Preserved by: Inline # codespell:ignore markers on comment references

@purva-thakre purva-thakre added this to the v0.10 milestone Jul 6, 2026
@purva-thakre purva-thakre changed the title Add codespell, consistent Am english style & correct typos Add codespell, consistent US english style & correct typos Jul 6, 2026
@purva-thakre
purva-thakre force-pushed the fix_typos branch 2 times, most recently from 0e284ba to 326000a Compare July 10, 2026 07:43
"RUNNING": JobStatus.RUNNING,
"DONE": JobStatus.DONE,
"CANCELLED": JobStatus.CANCELLED,
"CANCELED": JobStatus.CANCELLED,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a behavior change, we should not change this without veryfying that it still works

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean on actual hardware?

"RUNNING": JobStatus.RUNNING,
"DONE": JobStatus.DONE,
"CANCELLED": JobStatus.CANCELLED,
"CANCELED": JobStatus.CANCELLED,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another behavior change

@positr0nium positr0nium left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pushing this :) Some minor changes with API keywords in some backends.

@purva-thakre
purva-thakre force-pushed the fix_typos branch 2 times, most recently from 497c17b to 84ac927 Compare July 15, 2026 09:54

@bastibock bastibock left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for taking care of this Purva!
There were obviously quite some spelling mistakes in the codebase.

I flagged some more behavior changes that should be done automatically.

And did you check, that the documentation compiles correctly? Especially the two figures, that were marked as changed?

And for the future this would mean, that in case someone adds some function or parameter, they really have to be aware of the spelling. So if they want to intentionally spell something differently they have to exclude it manually, corrrect?

References
----------
- Childs et al. (2017) `Quantum algorithm for systems of linear equations with exponentially improved dependence on precision <https://arxiv.org/pdf/1511.02306>`_.
- Gilyén et al. (2019) `Quantum singular value transformation and beyond: exponential improvements for quantum matrix arithmetics <https://dl.acm.org/doi/abs/10.1145/3313276.3316366>`_.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep 'arithmetics' here, since this is the original title.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

References
----------
- Childs et al. (2017) `Quantum algorithm for systems of linear equations with exponentially improved dependence on precision <https://arxiv.org/pdf/1511.02306>`_.
- Gilyén et al. (2019) `Quantum singular value transformation and beyond: exponential improvements for quantum matrix arithmetics <https://dl.acm.org/doi/abs/10.1145/3313276.3316366>`_.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. Stick with 'arithmetics'

_DIAGONAL_1Q = frozenset({"p", "rz", "z", "s", "t", "s_dg", "t_dg", "id", "gphase"})


def _is_cancelled_by_zero(op: Operation, qubits: list[Qubit], fresh: set[Qubit]) -> bool:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also looks like an API change. But probably no problem to change it here, since it's only an internal method.

@purva-thakre purva-thakre Jul 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I figured since it's a private method, we don't need to worry about it.

"completed": JobStatus.DONE,
"failed": JobStatus.ERROR,
"cancelled": JobStatus.CANCELLED,
"canceled": JobStatus.CANCELLED,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like another behaviour change. Or is this conform with iqm structure?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, same as the others, this is a behavior change.

aqt_job = _make_aqt_job(fail=RuntimeError("canceled"))
aqt_job.status.return_value = MagicMock()
aqt_job.status.return_value.name = "CANCELLED"
aqt_job.status.return_value.name = "CANCELED"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More behaviour changes.
If the changes flagged from Raphael can be done, these are correct. Otherwise the tests have to stay the same as well for now.

@purva-thakre purva-thakre Jul 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that's the thing, with the changes flagged by @positr0nium , I figured they were good because the unit tests passed after I made the changes. But unless there is some behavior that is not covered by unit tests, I could make these changes later down the line.

qiskit_job = _make_qiskit_job(fail=RuntimeError("canceled"))
qiskit_job.status.return_value = MagicMock()
qiskit_job.status.return_value.name = "CANCELLED"
qiskit_job.status.return_value.name = "CANCELED"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More behaviour changes in the qiskit-backend test.

@purva-thakre

purva-thakre commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor Author

And for the future this would mean, that in case someone adds some function or parameter, they really have to be aware of the spelling. So if they want to intentionally spell something differently they have to exclude it manually, corrrect?

Yes, there is a check in the CI similar to ruff. It is setup such that the user gets a detailed message in case they see any errors related to bad spellings.

- name: Codespell
run: |
codespell || {
echo "::warning::The Qrisp project uses American English. Found spelling issues (see above)."
echo "::warning::Run 'codespell' locally to see the full list, or 'codespell -w' to auto-fix."
echo "::warning::To suppress: add '# codespell:ignore' to the line, or add the keyword to 'ignore-words-list' in pyproject.toml."
exit 1
}

I intentionally misspelled function as functon in d43248f and you can see this fails with the codespell warning. If I needed to ignore this line, I can do so via two options.

Screenshot from 2026-07-15 14-30-45

@purva-thakre

Copy link
Copy Markdown
Contributor Author

And did you check, that the documentation compiles correctly? Especially the two figures, that were marked as changed?

Good point. I did not check this initially 😅 .

codespell had corrupted the image data in ways I could not catch. It is fixed now and I also added a way to avoid making changes like this in the future via regex ignore.

@purva-thakre
purva-thakre force-pushed the fix_typos branch 2 times, most recently from fe3080d to a549dfa Compare July 15, 2026 13:42
Comment thread tests/interface_tests/test_job.py Resolved
@purva-thakre

purva-thakre commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor Author

The latest commits should address all the reviewer comments. As suggested by both, I went ahead and undid the behavior changes. I guess these are better handled with #706 (comment).

  1. Do we want to add a DeprecationWarning for the old names, use the new names and remove the older names after (say) v0.12 of Qrisp is released?
  2. Or is it better to rename the functions now and then add a RemovedFunction warning?

I ask this because there are a lot more incorrectly named functions. They were not flagged by codespell due to _ being in their names. We will have to manually change these. Below is the output when I asked an LLM to verify all function/variable names are not full of typos. Of course, I haven't dug too deeply in the LLM output yet, just an FYI. The ones that are the most important are the function name flags.


Findings

The Context column shows where the misspelling lives:

  • identifier — a real Python identifier (function/method/variable/parameter/keyword name)
  • string — inside a string literal or docstring
  • filename — module filename

1. ammend → amend

Identifier Context Role Files
ammend_inpl_adder identifier function adder_tools.py
ammend_cl_int identifier variable adder_tools.py
add_ammend_anc string — adder_tools.py

2. ammended → amended

Identifier Context Role Files
ammended_func identifier function custom_control_environment.py, custom_inversion_environment.py
ammended_function identifier function centerclass.py, qaching.py
ammended_adder identifier function adder_tools.py
ammended_args identifier variable custom_control_environment.py, boolean_simulation.py, qc_extraction_interpreter.py, centerclass.py
ammended_kwargs identifier variable centerclass.py, qaching.py

3. signficance → significance

Identifier Context Role Files
signficance_range_intersetion identifier variable adder_tools.py, ripple_carry_adder.py

4. dirtyness → dirtiness

Identifier Context Role Files
permit_dirtyness identifier variable adder_tools.py, backtracking_tree.py, from_projector.py, quantum_variable.py, quantum_float.py

5. multiplyer / multiplyers → multiplier / multipliers

Identifier Context Role Files
jasp_controlling_multiplyer identifier function jasp_multiplyers.py
jasp_controlling_multiplyer identifier variable __init__.py (jasp_arithmetic)
jasp_multiplyer identifier function jasp_multiplyers.py
jasp_multiplyer identifier variable __init__.py (jasp_arithmetic), quantum_float.py
jasp_multiplyers filename — jasp_multiplyers.py itself

6. spacial → spatial

Identifier Context Role Files
spacial_to_spin identifier function electronic_structure.py
num_spacial_orbs identifier variable electronic_structure.py

7. neighbour → neighbor

Identifier Context Role Files
_fuse_swap_with_neighbour identifier function fuse_adjacents.py

8. inital → initial

Identifier Context Role Files
inital_qvs identifier variable iteration_environment.py

9. burnin → burning / burn in

Identifier Context Role Files
num_burnin string — centerclass.py

10. cancelation → cancellation

Identifier Context Role Files
cancelation_bool string — rus.py

11. identifer → identifier

Identifier Context Role Files
alloc_identifer identifier variable memory_management.py

12. prefered → preferred

Identifier Context Role Files
prefered_nodes identifier variable memory_management.py

13. orignal → original

Identifier Context Role Files
orignal_shape_other identifier variable bi_arrays.py

Summary: 13 distinct misspellings, 11 in real Python identifiers + 2 in strings/filenames, across 15 files.

Of the 13, codespell's default config ([\w\-'’]+ tokenizer) would still flag some occurrences if the misspelled word appears as a standalone token in a comment or string. The blind spot is specifically when the misspelling is glued to another word via _, making it a single token. For example, ammend and burnin alone would each be caught, but ammend_inpl_adder and num_burnin are not.

@eclipse-qrisp eclipse-qrisp deleted a comment from github-actions Bot Jul 15, 2026
@renezander90

renezander90 commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

I would say we use option 1 for public facing (i.e. shown in the documentation) methods. But, we can directly rename internal methods or public examples.

For example:

  • cancelation_bool in rus.py only appears in the code example. This can be changed directly.
  • bi_arrays.py, memory_management.py are purely internal. Changes can be made directly.
  • spacial_to_spin is internal (not shown in documentation); num_spacial_orbs is internal; both can be changed directly.
  • The ammended methods are (likely) all internal.

@purva-thakre

Copy link
Copy Markdown
Contributor Author

going to start over with a new PR. There are way too many merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants