-
-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Give Pyright what it wants (
alias
attributes everywhere) (#3114)
* Pyright wants aliases everywhere * Changelog * Make backslash replacement more correct * Debug which class doesn't exist * Debug a bit better * Fix weirdness around PosixPath needing to be resolved * Appease type checker * Don't even consider tests in the alias test * Turn paths into strings before indexing * Explain the test better * Fixes for pre-commit * Reformat according to black * One last pre-commit fix * Simplify alias test by monkeypatching attrs. * Skip pyright init attributes test if plugin has not run * Catch any other renaming too * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Handle autoattribs * Disambiguate * Synchronise name * Update import mode because it worked locally * Check suspicions * Double check * Don't rely on installing `_trio_check_attrs_aliases.py` as a module * importlib import mode means we can use conftest again! * Just do something hacky instead * Debug and remove `-Wall` for later PR * Hopefully fix some things * Give into perl * Add perl to alpine (should work now) --------- Co-authored-by: Spencer Brown <spencerb21@live.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
f9411f4
commit cfbbe2c
Showing
9 changed files
with
81 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Ensure that Pyright recognizes our underscore prefixed attributes for attrs classes. |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"""Plugins are executed by Pytest before test modules. | ||
We use this to monkeypatch attrs.field(), so that we can detect if aliases are used for test_exports. | ||
""" | ||
|
||
from typing import Any | ||
|
||
import attrs | ||
|
||
orig_field = attrs.field | ||
|
||
|
||
def field(**kwargs: Any) -> Any: | ||
original_args = kwargs.copy() | ||
metadata = kwargs.setdefault("metadata", {}) | ||
metadata["trio_original_args"] = original_args | ||
return orig_field(**kwargs) | ||
|
||
|
||
# Mark it as being ours, so the test knows it can actually run. | ||
field.trio_modded = True # type: ignore | ||
attrs.field = field |