|
| 1 | +# < definition scip-python python scip-final-repro 0.1.0 contracts/__init__: |
| 2 | +#documentation (module) contracts |
| 3 | + |
| 4 | +# format-options: showDocs,showRanges |
| 5 | + |
| 6 | +from __future__ import annotations |
| 7 | +# ^^^^^^^^^^ reference python-stdlib 3.11 __future__/__init__: |
| 8 | +# external documentation ```python |
| 9 | +# > (module) __future__ |
| 10 | +# > ``` |
| 11 | +# external documentation --- |
| 12 | +# > |
| 13 | +# external documentation Record of phased-in incompatible languag... |
| 14 | +# > |
| 15 | +# > Each line is of the form: |
| 16 | +# > |
| 17 | +# > FeatureName = "\... |
| 18 | +# > &nbs... |
| 19 | +# > |
| 20 | +# > where, normally, OptionalRelease < Ma... |
| 21 | +# > of the same form as sys.version\_info: |
| 22 | +# > |
| 23 | +# > (PY\_MAJOR\_VERS... |
| 24 | +# > PY\_MINOR\... |
| 25 | +# > PY\_MICRO\_VERSION, # the 0; an int |
| 26 | +# > PY\_RELEASE\_LEVEL, # "alpha", "beta", "... |
| 27 | +# > PY\_RELEASE\_SERIAL # the 3; an int |
| 28 | +# > ) |
| 29 | +# > |
| 30 | +# > OptionalRelease records the first releas... |
| 31 | +# > |
| 32 | +# > from \_\_future\... |
| 33 | +# > |
| 34 | +# > was accepted. |
| 35 | +# > |
| 36 | +# > In the case of MandatoryReleases that ha... |
| 37 | +# > MandatoryRelease predicts the release in... |
| 38 | +# > of the language. |
| 39 | +# > |
| 40 | +# > Else MandatoryRelease records when the f... |
| 41 | +# > in releases at or after that, modules no... |
| 42 | +# > |
| 43 | +# > from \_\_future\... |
| 44 | +# > |
| 45 | +# > to use the feature in question, but may ... |
| 46 | +# > |
| 47 | +# > MandatoryRelease may also be None, meani... |
| 48 | +# > dropped. |
| 49 | +# > |
| 50 | +# > Instances of class \_Feature have two co... |
| 51 | +# > .getOptionalRelease() and .getMandatoryR... |
| 52 | +# > |
| 53 | +# > CompilerFlag is the (bitfield) flag that... |
| 54 | +# > argument to the builtin function compile... |
| 55 | +# > dynamically compiled code. This flag is... |
| 56 | +# > attribute on \_Future instances. These ... |
| 57 | +# > #defines of CO\_xxx flags in Include/cpy... |
| 58 | +# > |
| 59 | +# > No feature line is ever to be deleted fr... |
| 60 | +# ^^^^^^^^^^^ reference python-stdlib 3.11 __future__/annotations.annotations. |
| 61 | +# external documentation ```python |
| 62 | +# > (variable) annotations: _Feature |
| 63 | +# > ``` |
| 64 | + |
| 65 | +from dataclasses import dataclass |
| 66 | +# ^^^^^^^^^^^ reference python-stdlib 3.11 dataclasses/__init__: |
| 67 | +# external documentation ```python |
| 68 | +# > (module) dataclasses |
| 69 | +# > ``` |
| 70 | +# ^^^^^^^^^ reference python-stdlib 3.11 dataclasses/dataclass(). |
| 71 | +from numbers import Real |
| 72 | +# ^^^^^^^ reference python-stdlib 3.11 numbers/__init__: |
| 73 | +# external documentation ```python |
| 74 | +# > (module) numbers |
| 75 | +# > ``` |
| 76 | +# external documentation --- |
| 77 | +# > |
| 78 | +# external documentation Abstract Base Classes (ABCs) for numbers... |
| 79 | +# > |
| 80 | +# > TODO: Fill out more detailed documentati... |
| 81 | +# ^^^^ reference python-stdlib 3.11 numbers/Real# |
| 82 | +import math |
| 83 | +# ^^^^ reference python-stdlib 3.11 math/__init__: |
| 84 | + |
| 85 | + |
| 86 | +# < start enclosing_range scip-python python scip-final-repro 0.1.0 contracts/_validate(). |
| 87 | +def _validate(value: object) -> None: |
| 88 | +# ^^^^^^^^^ definition scip-final-repro 0.1.0 contracts/_validate(). |
| 89 | +# documentation ```python |
| 90 | +# > def _validate( |
| 91 | +# > value: object |
| 92 | +# > ) -> None: |
| 93 | +# > ``` |
| 94 | +# ^^^^^ definition scip-final-repro 0.1.0 contracts/_validate().(value) |
| 95 | +# ^^^^^^ reference python-stdlib 3.11 builtins/object# |
| 96 | +# external documentation ```python |
| 97 | +# > (class) object |
| 98 | +# > ``` |
| 99 | + if not isinstance(value, Foo): |
| 100 | +# ^^^^^^^^^^ reference local 0 |
| 101 | +# external documentation ```python |
| 102 | +# > (function) def isinstance( |
| 103 | +# > __obj: object, |
| 104 | +# > __class_or_tuple: _ClassInfo, |
| 105 | +# > / |
| 106 | +# > ) -> bool |
| 107 | +# > ``` |
| 108 | +# ^^^^^ reference scip-final-repro 0.1.0 contracts/_validate().(value) |
| 109 | +# ^^^ reference scip-final-repro 0.1.0 contracts/Foo# |
| 110 | + raise ValueError("must be Foo") |
| 111 | +# ^^^^^^^^^^ reference python-stdlib 3.11 builtins/ValueError# |
| 112 | +# external documentation ```python |
| 113 | +# > class ValueError(*args: object) |
| 114 | +# > ``` |
| 115 | + if not isinstance(value.x, Real) or not math.isfinite(value.x): |
| 116 | +# ^^^^^^^^^^ reference local 1 |
| 117 | +# external documentation ```python |
| 118 | +# > (function) def isinstance( |
| 119 | +# > __obj: object, |
| 120 | +# > __class_or_tuple: _ClassInfo, |
| 121 | +# > / |
| 122 | +# > ) -> bool |
| 123 | +# > ``` |
| 124 | +# ^^^^^ reference scip-final-repro 0.1.0 contracts/_validate().(value) |
| 125 | +# ^ reference scip-final-repro 0.1.0 contracts/Foo#x. |
| 126 | +# ^^^^ reference python-stdlib 3.11 numbers/Real# |
| 127 | +# ^^^^ reference python-stdlib 3.11 math/__init__: |
| 128 | +# ^^^^^^^^ reference python-stdlib 3.11 math/isfinite(). |
| 129 | +# ^^^^^ reference scip-final-repro 0.1.0 contracts/_validate().(value) |
| 130 | +# ^ reference scip-final-repro 0.1.0 contracts/Foo#x. |
| 131 | + raise ValueError("x must be finite real") |
| 132 | +# ^^^^^^^^^^ reference python-stdlib 3.11 builtins/ValueError# |
| 133 | +# < end enclosing_range scip-python python scip-final-repro 0.1.0 contracts/_validate(). |
| 134 | + |
| 135 | + |
| 136 | +# < start enclosing_range scip-python python scip-final-repro 0.1.0 contracts/Foo# |
| 137 | +@dataclass(frozen=True) |
| 138 | +#^^^^^^^^^ reference python-stdlib 3.11 dataclasses/dataclass(). |
| 139 | +# ^^^^^^ reference python-stdlib 3.11 dataclasses/dataclass().(frozen) |
| 140 | +# external documentation ```python |
| 141 | +# > (parameter) frozen: bool |
| 142 | +# > ``` |
| 143 | +class Foo: |
| 144 | +# ^^^ definition scip-final-repro 0.1.0 contracts/Foo# |
| 145 | +# documentation ```python |
| 146 | +# > @dataclass(frozen=True) |
| 147 | +# > class Foo: |
| 148 | +# > ``` |
| 149 | + x: float |
| 150 | +# ^ definition scip-final-repro 0.1.0 contracts/Foo#x. |
| 151 | +# documentation ```python |
| 152 | +# > (variable) x: float |
| 153 | +# > ``` |
| 154 | +# ^^^^^ reference python-stdlib 3.11 builtins/float# |
| 155 | +# external documentation ```python |
| 156 | +# > (class) float |
| 157 | +# > ``` |
| 158 | + |
| 159 | +# ⌄ start enclosing_range scip-python python scip-final-repro 0.1.0 contracts/Foo#__post_init__(). |
| 160 | + def __post_init__(self) -> None: |
| 161 | +# ^^^^^^^^^^^^^ definition scip-final-repro 0.1.0 contracts/Foo#__post_init__(). |
| 162 | +# documentation ```python |
| 163 | +# > def __post_init__( |
| 164 | +# > self |
| 165 | +# > ) -> None: |
| 166 | +# > ``` |
| 167 | +# ^^^^ definition scip-final-repro 0.1.0 contracts/Foo#__post_init__().(self) |
| 168 | + _validate(self) |
| 169 | +# ^^^^^^^^^ reference scip-final-repro 0.1.0 contracts/_validate(). |
| 170 | +# ^^^^ reference scip-final-repro 0.1.0 contracts/Foo#__post_init__().(self) |
| 171 | +# ^ end enclosing_range scip-python python scip-final-repro 0.1.0 contracts/Foo#__post_init__(). |
| 172 | +# < end enclosing_range scip-python python scip-final-repro 0.1.0 contracts/Foo# |
| 173 | + |
0 commit comments