-
Notifications
You must be signed in to change notification settings - Fork 0
Add an optional en-GB-oxendict spelling gate (default on) #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,30 @@ | |
|
|
||
|
|
||
| def dictionary_from_cache(repository: Path = REPOSITORY_ROOT) -> rollout.Dictionary: | ||
| """Load the cached shared base merged with local repository policy.""" | ||
| """Load cached shared policy merged with the repository overlay. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| repository : Path | ||
| Repository containing the refreshed cache and optional | ||
| ``typos.local.toml`` overlay. | ||
|
|
||
| Returns | ||
| ------- | ||
| rollout.Dictionary | ||
| Validated shared policy, with local additions merged when present. | ||
|
|
||
| Raises | ||
| ------ | ||
| OSError | ||
| A dictionary file cannot be read. | ||
| TypeError | ||
| A dictionary value has the wrong TOML shape. | ||
| ValueError | ||
| Dictionary policy is invalid or the overlay conflicts with the base. | ||
| tomllib.TOMLDecodeError | ||
| A dictionary file is not valid TOML. | ||
| """ | ||
| dictionary = rollout.load_dictionary(repository / ".typos-oxendict-base.toml") | ||
| local_overlay = repository / "typos.local.toml" | ||
| if local_overlay.exists(): | ||
|
|
@@ -35,7 +58,29 @@ def dictionary_from_cache(repository: Path = REPOSITORY_ROOT) -> rollout.Diction | |
|
|
||
|
|
||
| def render_config(repository: Path = REPOSITORY_ROOT) -> str: | ||
| """Render deterministic configuration from the populated local cache.""" | ||
| """Render deterministic configuration from the populated local cache. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| repository : Path | ||
| Repository containing the refreshed cache and optional local overlay. | ||
|
|
||
| Returns | ||
| ------- | ||
| str | ||
| Validated ``typos.toml`` content generated from the merged policy. | ||
|
|
||
| Raises | ||
| ------ | ||
| OSError | ||
| A dictionary file cannot be read. | ||
| TypeError | ||
| A dictionary value has the wrong TOML shape. | ||
| ValueError | ||
| Dictionary policy or generated word mappings conflict. | ||
| tomllib.TOMLDecodeError | ||
| Input or rendered output is not valid TOML. | ||
| """ | ||
| return rollout.render_typos_config(dictionary_from_cache(repository)) | ||
|
|
||
|
|
||
|
|
@@ -46,7 +91,42 @@ def main( | |
| source: str | Path = DEFAULT_BASE_URL, | ||
| offline: bool = False, | ||
| ) -> rollout.RefreshResult: | ||
| """Refresh the shared base cache and write the merged configuration.""" | ||
| """Refresh shared policy and write the merged generated configuration. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| output : Path | None | ||
| Generated configuration destination. Defaults to ``typos.toml`` in | ||
| ``repository``. | ||
| repository : Path | ||
| Repository that owns the cache, metadata, overlay, and output. | ||
| source : str | Path | ||
| Authoritative local dictionary path or HTTPS URL. | ||
| offline : bool | ||
| Reuse a valid cache without consulting ``source`` when true. | ||
|
|
||
| Returns | ||
| ------- | ||
| rollout.RefreshResult | ||
| Refresh status and the validated cache used to generate the output. | ||
|
|
||
| Raises | ||
| ------ | ||
| FileNotFoundError | ||
| Offline mode has no valid cache or a local source is absent. | ||
| OSError | ||
| Refresh, locking, or output filesystem operations fail. | ||
| TypeError | ||
| A dictionary value has the wrong TOML shape. | ||
| ValueError | ||
| A source, dictionary, merge, or generated mapping is invalid. | ||
| tomllib.TOMLDecodeError | ||
| Input or generated output is not valid TOML. | ||
| urllib.error.HTTPError | ||
| A remote refresh fails and no valid cache is available. | ||
| urllib.error.URLError | ||
| A network refresh fails and no valid cache is available. | ||
| """ | ||
|
Comment on lines
+94
to
+129
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Document The contract tests expect Based on learnings, the refresh must bound dictionary inputs and validate them before atomic replacement. Proposed docstring update ValueError
A source, dictionary, merge, or generated mapping is invalid.
+ rollout.DictionaryTooLargeError
+ A local or remote dictionary exceeds the fixed input limit.
tomllib.TOMLDecodeError🤖 Prompt for AI AgentsSource: Learnings |
||
| result = rollout.refresh_base( | ||
| source, | ||
| repository / ".typos-oxendict-base.toml", | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.