typo-guard 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- typo_guard-0.1.0/.github/CODE_OF_CONDUCT.md +128 -0
- typo_guard-0.1.0/.github/workflows/tests.yml +40 -0
- typo_guard-0.1.0/.gitignore +11 -0
- typo_guard-0.1.0/.pre-commit-hooks.yaml +8 -0
- typo_guard-0.1.0/.typo-guard-words +18 -0
- typo_guard-0.1.0/CHANGELOG.md +77 -0
- typo_guard-0.1.0/LICENSE +21 -0
- typo_guard-0.1.0/PKG-INFO +455 -0
- typo_guard-0.1.0/README.md +441 -0
- typo_guard-0.1.0/docs/MANUAL.md +866 -0
- typo_guard-0.1.0/docs/MANUAL.pdf +0 -0
- typo_guard-0.1.0/docs/images/allowlist-output.png +0 -0
- typo_guard-0.1.0/docs/images/clean-output.png +0 -0
- typo_guard-0.1.0/docs/images/compact-output.png +0 -0
- typo_guard-0.1.0/docs/images/error-handling-output.png +0 -0
- typo_guard-0.1.0/docs/images/grouped-output.png +0 -0
- typo_guard-0.1.0/docs/images/pipeline.mmd +20 -0
- typo_guard-0.1.0/docs/images/pipeline.png +0 -0
- typo_guard-0.1.0/docs/images/table-output.png +0 -0
- typo_guard-0.1.0/examples/.typo-guard-words +3 -0
- typo_guard-0.1.0/examples/clean_example.py +16 -0
- typo_guard-0.1.0/examples/example1.py +12 -0
- typo_guard-0.1.0/examples/example2.py +7 -0
- typo_guard-0.1.0/examples/example3.py +10 -0
- typo_guard-0.1.0/examples/example4.py +16 -0
- typo_guard-0.1.0/examples/example5.py +7 -0
- typo_guard-0.1.0/examples/example6.py +3 -0
- typo_guard-0.1.0/examples/example7.py +10 -0
- typo_guard-0.1.0/examples/example8.py +8 -0
- typo_guard-0.1.0/examples/example9.py +8 -0
- typo_guard-0.1.0/pyproject.toml +25 -0
- typo_guard-0.1.0/src/typo_guard/__init__.py +44 -0
- typo_guard-0.1.0/src/typo_guard/__main__.py +6 -0
- typo_guard-0.1.0/src/typo_guard/cli.py +223 -0
- typo_guard-0.1.0/src/typo_guard/core.py +305 -0
- typo_guard-0.1.0/src/typo_guard/py.typed +0 -0
- typo_guard-0.1.0/src/typo_guard/report.py +272 -0
- typo_guard-0.1.0/src/typo_guard/runner.py +120 -0
- typo_guard-0.1.0/tests/fixtures/__init__.py +0 -0
- typo_guard-0.1.0/tests/fixtures/original_core_0_1_0.py +186 -0
- typo_guard-0.1.0/tests/test_cli.py +161 -0
- typo_guard-0.1.0/tests/test_core.py +63 -0
- typo_guard-0.1.0/tests/test_engine_preserved.py +130 -0
- typo_guard-0.1.0/tests/test_examples.py +108 -0
- typo_guard-0.1.0/tests/test_hardening.py +378 -0
- typo_guard-0.1.0/tests/test_packaging.py +54 -0
- typo_guard-0.1.0/tests/test_report.py +227 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity
|
|
10
|
+
and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
|
18
|
+
community include:
|
|
19
|
+
|
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
+
and learning from the experience
|
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the
|
|
26
|
+
overall community
|
|
27
|
+
|
|
28
|
+
Examples of unacceptable behavior include:
|
|
29
|
+
|
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or
|
|
31
|
+
advances of any kind
|
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
+
* Public or private harassment
|
|
34
|
+
* Publishing others' private information, such as a physical or email
|
|
35
|
+
address, without their explicit permission
|
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
+
or harmful.
|
|
45
|
+
|
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
+
decisions when appropriate.
|
|
50
|
+
|
|
51
|
+
## Scope
|
|
52
|
+
|
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
+
an individual is officially representing the community in public spaces.
|
|
55
|
+
Examples of representing our community include using an official e-mail address,
|
|
56
|
+
posting via an official social media account, or acting as an appointed
|
|
57
|
+
representative at an online or offline event.
|
|
58
|
+
|
|
59
|
+
## Enforcement
|
|
60
|
+
|
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
+
reported to the community leaders responsible for enforcement
|
|
63
|
+
by contacting the project maintainer via GitHub.
|
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
+
|
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
+
reporter of any incident.
|
|
68
|
+
|
|
69
|
+
## Enforcement Guidelines
|
|
70
|
+
|
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
+
|
|
74
|
+
### 1. Correction
|
|
75
|
+
|
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
77
|
+
unprofessional or unwelcome in the community.
|
|
78
|
+
|
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
|
82
|
+
|
|
83
|
+
### 2. Warning
|
|
84
|
+
|
|
85
|
+
**Community Impact**: A violation through a single incident or series
|
|
86
|
+
of actions.
|
|
87
|
+
|
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
92
|
+
like social media. Violating these terms may lead to a temporary or
|
|
93
|
+
permanent ban.
|
|
94
|
+
|
|
95
|
+
### 3. Temporary Ban
|
|
96
|
+
|
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
|
98
|
+
sustained inappropriate behavior.
|
|
99
|
+
|
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
101
|
+
communication with the community for a specified period of time. No public or
|
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
104
|
+
Violating these terms may lead to a permanent ban.
|
|
105
|
+
|
|
106
|
+
### 4. Permanent Ban
|
|
107
|
+
|
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
111
|
+
|
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within
|
|
113
|
+
the community.
|
|
114
|
+
|
|
115
|
+
## Attribution
|
|
116
|
+
|
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
118
|
+
version 2.0, available at
|
|
119
|
+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
120
|
+
|
|
121
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
|
122
|
+
enforcement ladder](https://github.com/mozilla/diversity).
|
|
123
|
+
|
|
124
|
+
[homepage]: https://www.contributor-covenant.org
|
|
125
|
+
|
|
126
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
127
|
+
https://www.contributor-covenant.org/faq. Translations are available at
|
|
128
|
+
https://www.contributor-covenant.org/translations.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
test:
|
|
9
|
+
runs-on: ${{ matrix.os }}
|
|
10
|
+
strategy:
|
|
11
|
+
fail-fast: false
|
|
12
|
+
matrix:
|
|
13
|
+
os: [ubuntu-latest]
|
|
14
|
+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
15
|
+
include:
|
|
16
|
+
- os: windows-latest
|
|
17
|
+
python-version: "3.12"
|
|
18
|
+
- os: macos-latest
|
|
19
|
+
python-version: "3.12"
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v4
|
|
22
|
+
- uses: actions/setup-python@v5
|
|
23
|
+
with:
|
|
24
|
+
python-version: ${{ matrix.python-version }}
|
|
25
|
+
- name: Install
|
|
26
|
+
run: python -m pip install -e ".[dev]"
|
|
27
|
+
- name: Unit tests
|
|
28
|
+
run: python -m pytest
|
|
29
|
+
- name: typo-guard lints its own code
|
|
30
|
+
run: typo-guard lint src tests --allowlist .typo-guard-words
|
|
31
|
+
- name: Demo file is still detected (expects exit code 1)
|
|
32
|
+
shell: bash
|
|
33
|
+
run: |
|
|
34
|
+
set +e
|
|
35
|
+
typo-guard lint examples/example.py
|
|
36
|
+
test $? -eq 1
|
|
37
|
+
- name: Build and check distributions
|
|
38
|
+
run: |
|
|
39
|
+
python -m build
|
|
40
|
+
python -m twine check dist/*
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# typo-guard's own project vocabulary.
|
|
2
|
+
# CI runs: typo-guard lint src tests --allowlist .typo-guard-words
|
|
3
|
+
# One or more words per line; text after '#' is ignored.
|
|
4
|
+
|
|
5
|
+
# Python packaging and tooling jargon
|
|
6
|
+
allowlist changelog dunder filename linted linting pyproject subcommand subparsers traceback
|
|
7
|
+
|
|
8
|
+
# pytest fixtures and standard-library names
|
|
9
|
+
capsys monkeypatch isatty devnull dirs proc src symlink virtualenvs posix
|
|
10
|
+
|
|
11
|
+
# encodings and terminals
|
|
12
|
+
ansi bom crlf undecodable
|
|
13
|
+
|
|
14
|
+
# words used by the original 0.1.0 test-suite
|
|
15
|
+
recurses pre
|
|
16
|
+
|
|
17
|
+
# not in the smaller dictionary of pyspellchecker 0.8.x (the oldest supported version)
|
|
18
|
+
arg coloured
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
|
|
5
|
+
[Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [0.2.0] - 2026-11-04
|
|
8
|
+
|
|
9
|
+
This release keeps the 0.1.0 detection engine exactly as it was and rebuilds
|
|
10
|
+
everything around it: the output, the error handling, the documentation and the
|
|
11
|
+
test-suite.
|
|
12
|
+
|
|
13
|
+
### Preserved (unchanged from 0.1.0)
|
|
14
|
+
|
|
15
|
+
The following parts of `typo_guard/core.py` are structurally identical to 0.1.0.
|
|
16
|
+
`tests/test_engine_preserved.py` checks this against a verbatim copy of the 0.1.0
|
|
17
|
+
file (`tests/fixtures/original_core_0_1_0.py`). It also checks that both engines
|
|
18
|
+
return identical diagnostics on every example, source and test file in the repository.
|
|
19
|
+
|
|
20
|
+
- `_DefinitionVisitor`: which AST nodes count as variables, arguments, functions and classes.
|
|
21
|
+
- `split_identifier` and its three regular expressions (snake_case, camelCase, PascalCase, acronyms).
|
|
22
|
+
- `DEFAULT_ALLOWLIST`: the built-in programming vocabulary, Python keywords and built-in names.
|
|
23
|
+
- The word rules: skip words shorter than 3 letters, allowlisted words and digits, then look the word up in `pyspellchecker` with `distance=1`.
|
|
24
|
+
- Suggestion ranking: by dictionary word frequency, ties alphabetical, at most 3 by default.
|
|
25
|
+
- The `Diagnostic` record, the `TG001` text line format and the JSON schema.
|
|
26
|
+
- The public API (`lint_source`, `lint_file`, `lint_paths`, `split_identifier`, `extract_identifiers`) and the exit codes 0/1/2.
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
|
|
30
|
+
- **Table output (new default).** Findings are shown in a five-column table: Location, Kind, Identifier, Misspelled, Suggestions. Each column has its own colour, and the misspelled fragment is shown exactly as written (`Reponse`, not `reponse`).
|
|
31
|
+
- **Adaptive layout.** The full table is used when it fits the terminal. On a classic 80-column terminal the output switches to one table per file, with the path printed once as a heading. Very narrow terminals get a two-line-per-finding list. Piped or redirected output always gets the full table and is never cropped.
|
|
32
|
+
- **Summary line** with counts of typos, affected identifiers, affected files and scanned files, followed by a tip on how to allowlist words.
|
|
33
|
+
- `--format text` keeps the 0.1.0 one-line-per-finding output for scripts and editors. `--format json` is unchanged.
|
|
34
|
+
- `--exclude PATTERN` to skip directory or file names while recursing. Common tool directories (`.venv`, `venv`, `.git`, `__pycache__`, `build`, `dist`, `node_modules`, `*.egg-info`, ...) are skipped by default; explicit paths are always scanned.
|
|
35
|
+
- `--max-suggestions N`, `--color auto|always|never`, `--no-color`, `--exit-zero`, `--version`, and `python -m typo_guard`.
|
|
36
|
+
- Allowlist files now accept several words per line (space or comma separated), inline `#` comments and a UTF-8 BOM.
|
|
37
|
+
- `scan_paths()` / `ScanResult` / `FileError`: a fault-tolerant API that returns findings *and* per-file errors.
|
|
38
|
+
- `py.typed` marker, `.pre-commit-hooks.yaml`, a GitHub Actions workflow (Python 3.9 to 3.14 on Linux, plus Windows and macOS) and a project vocabulary file so typo-guard lints its own code.
|
|
39
|
+
- `docs/MANUAL.md`: the full instruction manual (installation, usage, internals, test guide, troubleshooting).
|
|
40
|
+
- 152 automated tests (0.1.0 had 14), including the ten manual acceptance cases from the 0.1.0 README, now automated.
|
|
41
|
+
|
|
42
|
+
### Fixed
|
|
43
|
+
|
|
44
|
+
Each of these was reproduced against 0.1.0 and is covered by a regression test in
|
|
45
|
+
`tests/test_hardening.py`.
|
|
46
|
+
|
|
47
|
+
- A file starting with a UTF-8 byte-order mark (common on Windows) failed with "invalid non-printable character U+FEFF". It is now linted normally.
|
|
48
|
+
- Files with a PEP 263 encoding declaration (for example `# -*- coding: latin-1 -*-`) failed to decode. They are now read the way the Python interpreter reads them.
|
|
49
|
+
- A NUL byte raised an uncaught `ValueError` traceback on Python 3.9 to 3.11. It is now reported as a syntax error on every version.
|
|
50
|
+
- Deeply nested source code crashed with an uncaught `MemoryError` and, worse, exited with code 1 ("typos found"). Very long expressions crashed with `RecursionError`. Both are now reported as "source too complex to analyse" with exit code 2.
|
|
51
|
+
- One unparsable file aborted the whole run and hid all other results. Every other file is now still reported, the error is listed per file, and the exit code is 2.
|
|
52
|
+
- A directory whose name ends in `.py` crashed the run with `IsADirectoryError`. It is now skipped.
|
|
53
|
+
- Scanning a project that contained a virtual environment failed on third-party (or Python 2) files. Such directories are now skipped by default.
|
|
54
|
+
- `SyntaxWarning`s that belong to the scanned code (for example `"\d"`) were printed to the terminal. They are now suppressed, and linting also works under `python -W error`.
|
|
55
|
+
- An explicit non-`.py` path was ignored silently. A warning is now shown, plus a warning when no Python file was found at all.
|
|
56
|
+
- The English dictionary was rebuilt for every file. Forty small files took about 9 seconds; they now take about 0.35 seconds.
|
|
57
|
+
- `max_suggestions=-1` silently dropped the last suggestion. Negative values now mean "no suggestions".
|
|
58
|
+
- `lint_source(..., allow_words="numpy")` treated the string as a list of letters. A single string is now one word.
|
|
59
|
+
- `typo-guard ... | head` printed a `BrokenPipeError` traceback. It is now silent.
|
|
60
|
+
- Output to a non-UTF-8 console could raise `UnicodeEncodeError`. Unsupported characters are now replaced, and box drawing and symbols fall back to ASCII.
|
|
61
|
+
- File names containing `[` `]` could be interpreted as terminal markup. All table cells are now plain text.
|
|
62
|
+
- A missing, directory or binary `--allowlist` produced a traceback. Each case now has a clear one-line error.
|
|
63
|
+
- Undecodable files are reported as "cannot decode file" with a hint, instead of a confusing "syntax error" that repeated the path.
|
|
64
|
+
- Any unexpected internal error now produces a one-line message and exit code 2 (set `TYPO_GUARD_DEBUG=1` for the traceback). Ctrl+C exits with code 130.
|
|
65
|
+
- Directory walking no longer follows symbolic links, so a symlink loop cannot hang the run.
|
|
66
|
+
|
|
67
|
+
### Changed
|
|
68
|
+
|
|
69
|
+
- The default output is the table. Use `--format text` for the exact 0.1.0 output.
|
|
70
|
+
- Two 0.1.0 CLI tests that compared the old text output now pass `--format text`; their assertions are otherwise unchanged.
|
|
71
|
+
|
|
72
|
+
## [0.1.0]
|
|
73
|
+
|
|
74
|
+
- Initial release: AST-based identifier extraction, naming-style-aware splitting, offline `pyspellchecker` lookup, allowlists, recursive linting, text and JSON output, CI exit codes.
|
|
75
|
+
|
|
76
|
+
[0.2.0]: https://github.com/your-org/typo-guard/compare/v0.1.0...v0.2.0
|
|
77
|
+
[0.1.0]: https://github.com/your-org/typo-guard/releases/tag/v0.1.0
|
typo_guard-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Group 20
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|