From 609af9309fe6542d3a3094ab1427742d1399127b Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Mon, 14 Mar 2022 10:07:18 +0100 Subject: [PATCH] Add missing attrs.converters/filters, fortify type tests Fixes #930 --- src/attrs/__init__.pyi | 4 +++- tests/typing_example.py | 28 ++++++++++++---------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/attrs/__init__.pyi b/src/attrs/__init__.pyi index 7426fa5dd..f99070891 100644 --- a/src/attrs/__init__.pyi +++ b/src/attrs/__init__.pyi @@ -23,13 +23,15 @@ from attr import __version_info__ as __version_info__ from attr import _FilterType from attr import assoc as assoc from attr import Attribute as Attribute +from attr import converters as converters from attr import define as define from attr import evolve as evolve -from attr import Factory as Factory from attr import exceptions as exceptions +from attr import Factory as Factory from attr import field as field from attr import fields as fields from attr import fields_dict as fields_dict +from attr import filters as filters from attr import frozen as frozen from attr import has as has from attr import make_class as make_class diff --git a/tests/typing_example.py b/tests/typing_example.py index a85c768c1..bb05af8f9 100644 --- a/tests/typing_example.py +++ b/tests/typing_example.py @@ -394,27 +394,23 @@ class MatchArgs2: attrs.astuple(MatchArgs2(1, 2)) -def importing_from_attr() -> None: +def accessing_from_attr() -> None: """ Use a function to keep the ns clean. """ - from attr.converters import optional - from attr.exceptions import FrozenError - from attr.filters import include - from attr.setters import frozen - from attr.validators import and_ + attr.converters.optional + attr.exceptions.FrozenError + attr.filters.include + attr.setters.frozen + attr.validators.and_ - assert optional and FrozenError and include and frozen and and_ - -def importing_from_attrs() -> None: +def accessing_from_attrs() -> None: """ Use a function to keep the ns clean. """ - from attrs.converters import optional - from attrs.exceptions import FrozenError - from attrs.filters import include - from attrs.setters import frozen - from attrs.validators import and_ - - assert optional and FrozenError and include and frozen and and_ + attrs.converters.optional + attrs.exceptions.FrozenError + attrs.filters.include + attrs.setters.frozen + attrs.validators.and_