File tree Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,9 @@ To be released.
10
10
11
11
- The ` uri ` type has completly gone; use ` url ` instead.
12
12
[[ #126 ] , [ #281 ] by Jonghun Park]
13
- - Added constraints for numeric unboxed types. [[ #206 ] , [ #271 ]]
13
+ - Added [ ` @numeric-constraints ` ] ( docs/annotation.md#numeric-constraints )
14
+ annotation to constraint the range of unboxed types' values.
15
+ [[ #206 ] , [ #271 ] by Seunghun Lee]
14
16
15
17
### Docs target
16
18
Original file line number Diff line number Diff line change @@ -132,12 +132,14 @@ class FileNotReadable(FileError):
132
132
133
133
### ` @numeric-constraints ` {#numeric-constraints}
134
134
135
- ` @numeric-constraints ` annotation constrain the range of the input value .
135
+ ` @numeric-constraints ` annotation constrains the range of unboxed types' values .
136
136
Currently, available annotation arguments are below:
137
137
138
- ` min ` : Minimum input value; inclusive
138
+ ` min `
139
+ : Minimum input value; inclusive.
139
140
140
- ` max ` : Maximum input value; inclusive
141
+ ` max `
142
+ : Maximum input value; inclusive.
141
143
142
144
For example, the following first Nirum code is compiled to the second Python
143
145
code:
@@ -148,13 +150,11 @@ unboxed month (int32);
148
150
~~~~~~~~
149
151
150
152
~~~~~~~~ python
151
- class Month (object ):
152
- ...
153
- def __init__ (self , value : ' __builtin__.int' ) -> None :
154
- ...
155
- if not (value <= (12 )):
153
+ class Month :
154
+ def __init__ (self , value : int ) -> None :
155
+ if not value <= 12 :
156
156
raise ValueError (" value is greater than 12" )
157
- if not ( value >= ( 1 )) :
157
+ if not value >= 1 :
158
158
raise ValueError (" value is less than 1" )
159
159
...
160
160
~~~~~~~~
You can’t perform that action at this time.
0 commit comments