From 6d3a66d947a57fed99dcb4bae47062cd9ce6a5f2 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sat, 26 Dec 2020 19:54:07 +0200 Subject: [PATCH] nodes: avoid needing to expose NodeKeywords for typing It adds no value over exporting just the ABC so do that to reduce the API surface. --- src/_pytest/nodes.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index da2a0a7ea..c6eb49dec 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -1,10 +1,12 @@ import os import warnings from pathlib import Path +from typing import Any from typing import Callable from typing import Iterable from typing import Iterator from typing import List +from typing import MutableMapping from typing import Optional from typing import overload from typing import Set @@ -148,8 +150,9 @@ class Node(metaclass=NodeMeta): #: Filesystem path where this node was collected from (can be None). self.fspath = fspath or getattr(parent, "fspath", None) + # The explicit annotation is to avoid publicly exposing NodeKeywords. #: Keywords/markers collected from all scopes. - self.keywords = NodeKeywords(self) + self.keywords: MutableMapping[str, Any] = NodeKeywords(self) #: The marker objects belonging to this node. self.own_markers: List[Mark] = []