feature_request(ignoring): ignoring words based on their context
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start by reviewing the related issues (#410, #2491, and #3673), then inspect how Codespell currently handles configuration and ignored words. Done means users can configure words to be ignored only for specified contexts and file extensions, while still receiving warnings in other cases; the issue gives four example cases to check.
索引モデルが issue の本文から書いたものです。
説明
Related issues: #410, #2491, #3673.
1. Summary
It would be nice if Codespell will allow ignoring words based on their context.
2. Justification of the need of the feature
This was discussed in several issues of this repository. It would be nice to have behavior where Codespell ignore words solely in specific cases but continues to return warnings for all another cases.
3. Example of desired behavior
Example YAML configuration file with keys context and extensions. Examples in this file are false positives from my project.
# [OVERVIEW] Example of a Codespell configuration file for ignoring words based on their context:
#
#
# [KEYS] Both keys are optional, but at least one of them must exists.
#
# 1. “context” — the list of contexts in which the word is ignored. List items are case-sensitive.
# If the key doesn’t exist, Codespell will ignore the word in any context.
#
# 2. “extensions” — the list of extensions for which the word is ignored.
# If the key doesn’t exist, Codespell will ignore the word for any extension.
#############
# Example 1 #
#############
# [PURPOSE] I want to get Codespell warnings for the “colour” word
# except the case where this word is used in the phrase “Colour Contrast Checker”.
#
# [INFO] “Colour Contrast Checker” is the name of the online application:
# https://github.com/Pushedskydiver/Colour-Contrast-Checker
colour:
context:
- Colour Contrast Checker
#############
# Example 2 #
#############
# [PURPOSE] I want to get Codespell warnings for the “isnt” typo,
# but not for the CoffeeScript built-in operator “isnt”:
# https://coffeescript.org/#operators
isnt:
extensions:
- coffee
#############
# Example 3 #
#############
# [PURPOSE] I want to get Codespell warnings for the “nd” typo,
# but not for the class “.nd” from the Pygments library in my CSS and Stylus files:
#
# [NOTE] I preferred more informative class names than “.nd”, but Pygments developers have the another opinion:
# https://github.com/richleland/pygments-css/blob/146834e1f9476d517c10cee5f15381047866d93d/monokai.css#L34
nd:
context:
- .nd
extensions:
- css
- styl
#############
# Example 4 #
#############
# [PURPOSE] I want to get Codespell warnings for the “whos” typo,
# but not for the IPython built-in magic command “%whos”:
# https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-whos
whos:
context:
- "%whos"
extensions:
- py
If this file exists, Codespell will ignore colour, isnt, nd and whos for contexts provided in the file.
It would be nice if Codespell will support something like this configuration file.
4. Alternatives of context+extension ignoring
4.1. Inline ignoring
I’m not sure that codespell:ignore comments is the best solution for users.
- If a user gets the same false positive multiple times, he needs to add
codespell:ignorecomments multiple times. If a configuration file as in my example would be allowed, it would be enough for a user to make one record in a configuration. - I try not to use inline ignoring at all and prefer ignoring via the configuration if it’s possible. In my opinion, it would be nice if text files contains solely texts and code files contains solely code without records especially for checkers/linters/validators.
- Unfortunately, currently Codespell by default doesn’t provide an opportunity ignoring words based on their context. But I hope that someday it will become possible, and users can make pull requests based on their personal configurations for cases like
%whosfrom my example.
4.2. Per-file ignoring
In my opinion, it would be nice, that the pull request #3675 allows ignoring based on extensions, but I’m not sure that ignoring per file is the best idea. The file may contain both false positives and real typos, and if a user activate the option --per-file-ignores, he may skip real typos. The context key from my example would allow more accurate ignoring.
Thanks.
- 主要言語
- Python
- スター
- 2.4k
- フォーク
- 531
- 平均マージ
- 15時間 5分
- マージ済み PR(30日)
- 18
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
codespell-project/codespell のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
codespell-project/codespell#3997 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
codespell-project/codespell#3965 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
Add "marcos"対応中かも @ekanshul が 19 日前に担当しました。 オープンdictionary
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
codespell-project/codespell#3920 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
question
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
codespell-project/codespell#4005 ·
メンテナーはふだん 1 日以内に返信
-
duplicate question
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
codespell-project/codespell#3998 ·
メンテナーはふだん 1 日以内に返信
codespell-project/codespell の issue をすべて見る
似ている issue
-
area/profiles comp/cli P3 type/feature
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
NousResearch/hermes-agent#146372 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
[oblt-aw][autodoc] Document obs-aw-automerge contract and fix automerge doc inconsistencies対応中かも @github-actions が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
GeoSeries scale and skew tests fail with pytest 9.2.0対応中かも @jiayuasu が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
admission-deferred priority: medium status: ready work-class: scoped
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
melodic-software/claude-code-plugins#10887 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信