Skip to content

Introducing spell checking and fixing several typos#934

Open
KostaIlic2 wants to merge 45 commits intoni:masterfrom
KostaIlic2:users/kosta/cspell-one-project-dictionary
Open

Introducing spell checking and fixing several typos#934
KostaIlic2 wants to merge 45 commits intoni:masterfrom
KostaIlic2:users/kosta/cspell-one-project-dictionary

Conversation

@KostaIlic2
Copy link

  • This contribution adheres to CONTRIBUTING.md.
    I have not run tests locally

TODO: Check the above box with an 'x' indicating you've read and followed CONTRIBUTING.md.

TODO: Check the above box with an 'x' if considered if there were any and then documented client facing changes in CHANGELOG.md. Strike through if this is not a relevant client facing change.

  • I've added tests applicable for this pull request

TODO: Check the above box with an 'x' indicating you have considered and added any applicable system or unit tests. Strike through if you considered and decided additional tests were not warranted.

What does this Pull Request accomplish?

I introduced configuration and dictionaries for cspell spell checker. I fixed several typos.

Why should this Pull Request be merged?

To eliminate typos present now and reduce probability of typos in the future.

What testing has been done?

I ran all static checks and generated documentation. And I ran the spell checker.
I skipped regression tests. I hope PR CI covers that.

Add cspell spell-checking configuration:
- cspell.json with file/path scoping and Mako template override
- cspell-dict.txt for project-specific technical terms
- cspell-ignore-words.txt for known abbreviations and API identifiers
- cspell-mako-keywords.txt for Mako template keywords

Fix spelling errors in variable, function, file names, comments,
docstrings, and test names throughout the codebase.
- Set noSuggest on all dictionaries so project-specific terms don't
  pollute suggestion lists
- Add cspell-dict and cspell-daqmx-abbreviations to the Mako template
  override so abbreviations are recognized in templates
- Merge duplicate entries in cspell-daqmx-abbreviations.txt (e.g.
  Conn # Connect / Connected / Connecting / Connector)
- Add '# Real words' section header to cspell-dict.txt
…docs

- Replace files allowlist with ignorePaths blocklist and useGitignore: true
- Add docs/**/*.rst to spell-check scope
- Add .cspell/cspell-sphinx-directives.txt dictionary for Sphinx RST directives
- Add *.rst override to apply Sphinx directives dictionary
- Add per-file dictionaries and overrides for CHANGELOG.md and CONTRIBUTING.md
- Add .cspell/cspell-changelog-words.txt with historical identifiers and bot names
- Add .cspell/cspell-contributing-words.txt with contribution workflow terms
- Add package names to cspell-dict.txt (numpy, ctypes, pytest, matplotlib, pyplot)
- Add HWCU and NIDAQ to cspell-dict.txt
- Add bitfields plural form to cspell-dict.txt
- Add backlinks to cspell-sphinx-directives.txt
- Add python dictionary to .rst override for code examples
- fix: correct domaindirectives typo in CHANGELOG.md
@KostaIlic2
Copy link
Author

Abbreviations file will need some additional work

Copy link
Collaborator

@zhindes zhindes left a comment

Choose a reason for hiding this comment

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

I spot-checked everything, and it looks really nice. I don't live node in the workflow, but its not the worst, and the benefit seems good. Unless somebody knows an obvious alternative, I think I'm down. But! Let's block on Brad's review, too.

@@ -0,0 +1,168 @@
# Real words
nidaqmx
Copy link
Collaborator

Choose a reason for hiding this comment

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

heck ya nidaqmx is a word!

imports and format the code with Black, then manually fix any remaining errors.
10. Run `poetry run mypy` to statically type-check the updated code.
11. Send a GitHub Pull Request to the main repository's master branch. GitHub Pull Requests are the
11. Run `npx cspell "**" --no-progress` to check for spelling errors. This requires [Node.js](https://nodejs.org/) to be installed.
Copy link
Collaborator

Choose a reason for hiding this comment

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

How bad is it if engineers just wait for the PR to do it for them? At least for a while people will stumble into it. Does the error reporting look good?

Copy link
Author

Choose a reason for hiding this comment

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

I can see a workflow where engineers wait on the PR to do everything for them. Is there a reason to treat spell checking differently from other static analysis chores?

I think that reporting of "unknown words" is reasonable:
image

Copy link
Collaborator

Choose a reason for hiding this comment

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

FYI, Zach is OOO

install_commands: list[list[str]]


# Mapping of distros to their command templates and version handlers
Copy link
Collaborator

Choose a reason for hiding this comment

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

"distro" and "distros" are used often enough that I think we should consider them to be words

Copy link
Author

@KostaIlic2 KostaIlic2 Mar 8, 2026

Choose a reason for hiding this comment

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

distros is used in exactly one location in this body of code.

I did not add distro to the list because the singular form is already present in the software terms built-in dictionary.

I believe that the authors of that dictionary have given thought to plural form of such industry specific abbreviations.

Do you think that the readers of the comment will be confused by the fully spelled out word?

This seems like another candidate for a document about spelling.

import typing

# region Task Counter IO namedtuples
# region Task Counter IO named tuples
Copy link
Collaborator

Choose a reason for hiding this comment

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

namedtuple is a type word, I think we should allow namedtuple and namedtuples

Copy link
Author

@KostaIlic2 KostaIlic2 Mar 8, 2026

Choose a reason for hiding this comment

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

namedtuples is used in exactly one location in this body of code.

namedtuple is in cspell built-in python dictionary, and namedtuples is not.

I personally find the two real words with a space in between in the comment easier to understand. Do you think that this spelling will confuse any readers of the comment?

I prefer not to add plural form to our dictionary.

Objections?

Copy link
Collaborator

@bkeryan bkeryan Mar 13, 2026

Choose a reason for hiding this comment

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

@mshafer-NI Here's what I think:

In prose, it is acceptable to convert class names to prose. For example, "Returns a GrpcEventHandler" -> "Returns a gRPC event handler".

It is also acceptable to use the class name as a modifier for another noun (kind of like a trademark). For example, "Returns a GrpcEventHandler" -> "Returns a GrpcEventHandler object".

Either of these techniques can be used to avoid pluralizing a class name. For example, "Returns a collection of GrpcEventHandlers" -> "Returns a collection of gRPC event handlers" or "Returns a collection of GrpcEventHandler objects".

Also, I thought I converted all of these namedtuple classes to use typing.NamedTuple. 😅

@bkeryan
Copy link
Collaborator

bkeryan commented Mar 6, 2026

Let's block on Brad's review, too.

Thanks. I will try to take a look at this later today.

Copy link
Collaborator

Choose a reason for hiding this comment

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

https://peps.python.org/pep-0008/#package-and-module-names

Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability.

IMO "_dotenvpath.py" is sufficiently readable.

Also, "dot" and "env" are separate words. The fact that there is a deprecated package we are not using called https://pypi.org/project/dotenv/ is a result of the Python naming conventions saying that separating words with underscores is optional.

Copy link
Author

Choose a reason for hiding this comment

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

Interesting that the wording in PEP-8 is slightlty different for module names and variable/function names.

Given the wording for module names, I can argue that adding the underscore improves readability. The guide does not make inclusion of underscores conditional on insufficient readability without the underscores.

Copy link
Author

Choose a reason for hiding this comment

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

I created #938 to remember to rename the file in a separate PR.

@KostaIlic2 KostaIlic2 force-pushed the users/kosta/cspell-one-project-dictionary branch from 742255f to 5f0f91a Compare March 8, 2026 03:33
cspell treats \b as a regex metacharacter, so r"\bnptdms\b" produces
the token nptdms, which is already in the dictionary. The bnptdms
entry was never needed.
@KostaIlic2 KostaIlic2 force-pushed the users/kosta/cspell-one-project-dictionary branch from 7070eb2 to 2aad129 Compare March 8, 2026 03:44
@KostaIlic2
Copy link
Author

KostaIlic2 commented Mar 8, 2026

@bkeryan, @mshafer-NI, @zhindes,

To reduce the number of dictionary files, I tried two alternative approaches for two markdown files - both based on inlining cspell:ignore instead of custom dictionaries.

CONTRIBUTING.md: one word per line at the top of the file — simple, easy to maintain, but adds noise before the prose.

CHANGELOG.md: one comment immediately above the line where each term is introduced — better locality, and the ignore naturally disappears if the entry is ever removed.

The trade-off vs. dictionary files is discoverability: someone maintaining the file can see exactly why a word is ignored and where it comes from, without having to cross-reference the .cspell/ folder. However, dictionary files keep all custom words in one place and don't touch the source documents.

I would appreciate your feedback on this topic. Do you have a preference between the three approaches?

... 2 days later
After some reflection, and in absence of feedback, I decided to get rid of the dictionaries for these one-off files and introduce localized cspell:ignore directives.

@KostaIlic2
Copy link
Author

KostaIlic2 commented Mar 8, 2026

We have redundancy in coverage for two markdown files for discussion purposes. After the discussion is over, I need to remove the redunancy

... 2 days later.
This is resolved.

Add .cspell/cspell-codegen-dict.txt with ~115 entries covering
NI-DAQmx initialisms, abbreviations, compound identifiers, typos
locked in public API names, and real domain words specific to
codegen and generated source files.

Update cspell.json:
- Add cspell-codegen-dict dictionary definition
- Remove broad generated/** and src/codegen/** ignore paths so
  these files are now spell-checked
- Add generated/nidaqmx/_stubs/** back to ignorePaths (protobuf
  stubs are too noisy to check)
- Add override applying cspell-codegen-dict to src/codegen/**
  and generated/**
- Sort dictionaryDefinitions alphabetically
- Order ignorePaths to match VSCode Explorer layout
- Add ordering comments to both lists

Fix typos in metadata source (src/codegen/metadata/attributes.py):
- specfied -> specified
- thermcouple -> thermocouple
- thefilter -> the filter (two occurrences)

These propagate into generated files via codegen; also fix them
directly in the generated files that are already up to date.

Minor code fixes:
- src/codegen/generator.py: docstring "Codegenerator" -> "Code generator"
- src/codegen/stub_generator.py: rename grpc_codegened_file_paths
  -> grpc_code_generated_file_paths
- Remove pyproject.toml from cspell.json ignorePaths
- Add cspell override for pyproject.toml with [cspell-dict,
  cspell-daqmx-abbreviations, python] dictionaries; the python
  dictionary covers: mypy, pypy, grpcio, tzlocal, doctest,
  filterwarnings, xfail
- Add // cspell:disable-line to the override's filename line in
  cspell.json to suppress pyproject in that string literal
- Suppress maintainer names (Hindes, Maxx, Boehme, Keryan) using
  # cspell:disable / # cspell:enable around the maintainers block
- Add # cspell:ignore addopts above [tool.pytest.ini_options].addopts
- Add # cspell:ignore testpaths above [tool.pytest.ini_options].testpaths
- Add grpcdevice and styleguide to .cspell/cspell-dict.txt
- Remove grpcdevice from .cspell/cspell-changelog-words.txt
- Remove styleguide from .cspell/cspell-changelog-words.txt and
  .cspell/cspell-contributing-words.txt
- Remove <!-- cspell:ignore styleguide --> from CONTRIBUTING.md
- Remove <!-- cspell:ignore styleguide --> and
  <!-- cspell:ignore grpcdevice --> from CHANGELOG.md
…nary

Improve comments in cspell-daqmx-api-elements.txt for consistency:
- Use specific comment taxonomy: abbreviation, unseparated words,
  unseparated initialisms, initialism, Typo, Deprecated
- Move mioDAQ to cspell-real-words.txt
- Move forcebridge/pressurebridge/torquebridge to
  cspell-project-software-terms.txt (typo: filenames should be PascalCase)
- Move installdriver to cspell-project-software-terms.txt (CLI command)
- Reclassify BBULK, COULDNT, DOESNT, DAQError, notKnown, zidx
  with accurate comments instead of 'compatibility breaking name'
forcebridge.ted → ForceBridge.ted
pressurebridge.ted → PressureBridge.ted
torquebridge.ted → TorqueBridge.ted

Update conftest.py fixtures and remove the words from the cspell dictionary.
- Remove redundant "Real word:" and "Initialism:" prefixes from comments
- Lowercase entries that are neither initialisms nor proper nouns
- Add descriptions to bare entries
- Standardize GPS initialism comments
- Correct SMIO expansion: Serial Memory I/O -> Simultaneously-sampling Multifunction I/O
This was referenced Mar 10, 2026
- Move cspell.json to .config/cspell.json
- Move .cspell/ dictionary files to .config/cspell/, dropping the
  redundant "cspell-" prefix from each filename and dictionary name
- Add globRoot: "${cwd}" so paths resolve correctly from the new location
- Set noSuggest: false on real-words to enable spelling suggestions
Copy link
Collaborator

@bkeryan bkeryan left a comment

Choose a reason for hiding this comment

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

Approved with suggestions: update PR description and CHANGELOG.md

Copy link
Collaborator

Choose a reason for hiding this comment

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

This metadata comes from one of our internal Git repos. I will post a PR to fix it there so this doesn't get reverted the next time someone updates this file based on the internal metadata.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This contribution adheres to CONTRIBUTING.md.
I have not run tests locally
TODO: Check the above box with an 'x' indicating you've read and followed CONTRIBUTING.md.

That's okay. Everything passes in the PR workflow, except for "Run system tests (win-10-py32)" which is an intermittent issue with the self-hosted runner used for that job.

I've updated CHANGELOG.md if applicable.
TODO: Check the above box with an 'x' if considered if there were any and then documented client facing changes in CHANGELOG.md. Strike through if this is not a relevant client facing change.

Please add a bullet point saying the project now uses cspell for spell checking.

We forgot to add the 1.5.0 section after releasing 1.4.0, so please add it to the top:

## 1.5.0
* ### Merged Pull Requests
    * [Full changelog: 1.4.0...1.5.0](https://github.com/ni/nidaqmx-python/compare/1.5.0...1.5.0)

* ### Resolved Issues
    * ...

* ### Major Changes
    * ...

* ### Known Issues
    * ...

I've added tests applicable for this pull request
TODO: Check the above box with an 'x' indicating you have considered and added any applicable system or unit tests. Strike through if you considered and decided additional tests were not warranted.

Strike through this, e.g. - [ ] ~~blah blah~~

Copy link
Collaborator

Choose a reason for hiding this comment

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

We forgot to add the 1.5.0 section after releasing 1.4.0, so please add it to the top:

Correction: this was done a month ago. Please rebase/merge against the latest master branch.

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