# Copyright (C) 2016-present the asyncpg authors and contributors# <see AUTHORS file>## This module is part of asyncpg and is released under# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0from__future__importannotationsimporttypingfromasyncpg.pgproto.typesimport(BitString,Point,Path,Polygon,Box,Line,LineSegment,Circle,)iftyping.TYPE_CHECKING:fromtyping_extensionsimportSelf__all__=('Type','Attribute','Range','BitString','Point','Path','Polygon','Box','Line','LineSegment','Circle','ServerVersion',)[docs]classType(typing.NamedTuple):oid:intname:strkind:strschema:str Type.__doc__='Database data type.'Type.oid.__doc__='OID of the type.'Type.name.__doc__='Type name. For example "int2".'Type.kind.__doc__= \'Type kind. Can be "scalar", "array", "composite" or "range".'Type.schema.__doc__='Name of the database schema that defines the type.'[docs]classAttribute(typing.NamedTuple):name:strtype:Type Attribute.__doc__='Database relation attribute.'Attribute.name.__doc__='Attribute name.'Attribute.type.__doc__='Attribute data type :class:`asyncpg.types.Type`.'[docs]classServerVersion(typing.NamedTuple):major:intminor:intmicro:intreleaselevel:strserial:int ServerVersion.__doc__='PostgreSQL server version tuple.'class_RangeValue(typing.Protocol):def__eq__(self,__value:object)->bool:...def__lt__(self,__other:Self,/)->bool:...def__gt__(self,__other:Self,/)->bool:..._RV=typing.TypeVar('_RV',bound=_RangeValue)[docs]classRange(typing.Generic[_RV]):"""Immutable representation of PostgreSQL `range` type."""__slots__=('_lower','_upper','_lower_inc','_upper_inc','_empty')_lower:_RV|None_upper:_RV|None_lower_inc:bool_upper_inc:bool_empty:booldef__init__(self,lower:_RV|None=None,upper:_RV|None=None,*,lower_inc:bool=True,upper_inc:bool=False,empty:bool=False)->None:self._empty=emptyifempty:self._lower=self._upper=Noneself._lower_inc=self._upper_inc=Falseelse:self._lower=lowerself._upper=upperself._lower_inc=lowerisnotNoneandlower_incself._upper_inc=upperisnotNoneandupper_inc@propertydeflower(self)->_RV|None:returnself._lower@propertydeflower_inc(self)->bool:returnself._lower_inc@propertydeflower_inf(self)->bool:returnself._lowerisNoneandnotself._empty@propertydefupper(self)->_RV|None:returnself._upper@propertydefupper_inc(self)->bool:returnself._upper_inc@propertydefupper_inf(self)->bool:returnself._upperisNoneandnotself._empty@propertydefisempty(self)->bool:returnself._emptydef_issubset_lower(self,other:Self)->bool:ifother._lowerisNone:returnTrueifself._lowerisNone:returnFalsereturnself._lower>other._loweror(self._lower==other._lowerand(other._lower_incornotself._lower_inc))def_issubset_upper(self,other:Self)->bool:ifother._upperisNone:returnTrueifself._upperisNone:returnFalsereturnself._upper<other._upperor(self._upper==other._upperand(other._upper_incornotself._upper_inc))defissubset(self,other:Self)->bool:ifself._empty:returnTrueifother._empty:returnFalsereturnself._issubset_lower(other)andself._issubset_upper(other)defissuperset(self,other:Self)->bool:returnother.issubset(self)def__bool__(self)->bool:returnnotself._emptydef__eq__(self,other:object)->bool:ifnotisinstance(other,Range):returnNotImplementedreturn(self._lower,self._upper,self._lower_inc,self._upper_inc,self._empty)==(other._lower,# pyright: ignore [reportUnknownMemberType]other._upper,# pyright: ignore [reportUnknownMemberType]other._lower_inc,other._upper_inc,other._empty)def__hash__(self)->int:returnhash((self._lower,self._upper,self._lower_inc,self._upper_inc,self._empty))def__repr__(self)->str:ifself._empty:desc='empty'else:ifself._lowerisNoneornotself._lower_inc:lb='('else:lb='['ifself._lowerisnotNone:lb+=repr(self._lower)ifself._upperisnotNone:ub=repr(self._upper)else:ub=''ifself._upperisNoneornotself._upper_inc:ub+=')'else:ub+=']'desc='{},{}'.format(lb,ub)return'<Range{}>'.format(desc)__str__=__repr__