[BUG] Prevent domain names from triggering WPS347#3657
Open
webknjaz wants to merge 1 commit into
Open
Conversation
When having `flake8-typing-as-t` that enforces a pallets-originating convention of doing `import t as t`. I have it configured with the `import t as _t` enforcement mode. To follow the same convention with typing-only imports from other modules, I also import the `collections.abc` module similarly:
```python
import typing as _t
if _t.TYPE_CHECKING:
from collections import abc as _c
```
That `from collections import abc as _c` line incorrectly trips the WPS347 rule check claiming that it's vague.
I however correctly set the `_c` as a domain name as follows:
```ini
# .flake8
# flake8-typing-as-t
# TYT02:
typing-as-t-imported-name = _t
# wemake-python-styleguide
# WPS111:
# `_t` will be enforced by `flake8-typing-as-t`
allowed-domain-names =
_t,
_c,
```
This patch makes the check respect the `allowed-domain-names` setting thus preventing WPS from reporting a false-positive match.
This is a promptly checked change via a local `site-packages` modification but is coded in-browser without any additional validation or testing. Feel free to push additional tests into the branch.
sobolevn
reviewed
May 29, 2026
Member
sobolevn
left a comment
There was a problem hiding this comment.
Sounds like a good idea :)
Please, fix the CI.
Contributor
Author
|
I marked it as a drive-by since it's not a priority. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When having
flake8-typing-as-tthat enforces a pallets-originating convention of doingimport t as t. I have it configured with theimport t as _tenforcement mode. To follow the same convention with typing-only imports from other modules, I also import thecollections.abcmodule similarly:That
from collections import abc as _cline incorrectly trips the WPS347 rule check claiming that it's vague.I however correctly set the
_cas a domain name as follows:This patch makes the check respect the
allowed-domain-namessetting thus preventing WPS from reporting a false-positive match.This is a promptly checked change via a local
site-packagesmodification but is coded in-browser without any additional validation or testing. Feel free to push additional tests into the branch.Checklist
CHANGELOG.md