Skip to content

Commit a435b2b

Browse files
committed
Class allowing to formally specify additional information
1 parent 3ec4f22 commit a435b2b

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

pyannotating.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
from abc import ABC, abstractmethod
2-
from typing import Union, Iterable, Optional, Self, Mapping, Final, Callable, _UnionGenericAlias
2+
from typing import Optional, Union, Iterable, Self, Mapping, Final, Callable, _UnionGenericAlias
3+
4+
5+
class FormalAnnotation:
6+
"""
7+
Class allowing to formally specify additional information about the input
8+
resource.
9+
10+
When annotating, returns the input.
11+
12+
Can be called via [] with some resource.
13+
"""
14+
15+
def __init__(self, instance_doc: Optional[str] = None):
16+
if instance_doc is not None:
17+
self.__doc__ = instance_doc
18+
19+
def __repr__(self) -> str:
20+
return f"<{self.__class__.__name__}>"
21+
22+
def __getitem__(self, resource: any) -> any:
23+
return resource
324

425

526
class AnnotationFactory(ABC):

0 commit comments

Comments
 (0)