You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-8Lines changed: 11 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -24,10 +24,11 @@ Make your functions return something meaningful, typed, and safe!
24
24
pip install returns
25
25
```
26
26
27
-
You might also need to [configure](https://returns.readthedocs.io/en/latest/pages/container.html#type-safety)
27
+
You might also want to [configure](https://returns.readthedocs.io/en/latest/pages/container.html#type-safety)
28
28
`mypy` correctly and install our plugin:
29
29
30
30
```ini
31
+
# In setup.cfg or mypy.ini:
31
32
[mypy]
32
33
plugins =
33
34
returns.contrib.mypy.decorator_plugin
@@ -225,20 +226,20 @@ It really bloats your source code and makes it unreadable.
225
226
But, having `None` in your source code is even worth.
226
227
Actually, `None` is called the [worth mistake in the history of Computer Science](https://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare/).
227
228
228
-
So, what to do? Use `Maybe` container!
229
-
It consists of `Some(...)` and `Nothing` types,
230
-
representing existing state and `None` state respectively.
229
+
So, what to do?
230
+
Use [Maybe](https://returns.readthedocs.io/en/latest/pages/maybe.html) container!
231
+
It consists of `Some` and `Nothing` types,
232
+
representing existing state and empty (or `None`) state respectively.
231
233
232
234
```python
233
235
from typing import Optional
234
-
from returns.maybe import Maybe
236
+
from returns.maybe import Maybe, maybe
235
237
238
+
@maybe
236
239
defbad_function() -> Optional[int]:
237
240
...
238
241
239
-
maybe_result: Maybe[float] = Maybe.new(
240
-
bad_function(),
241
-
).map(
242
+
maybe_result: Maybe[float] = bad_function().map(
242
243
lambdanumber: number /2,
243
244
)
244
245
# => Maybe will return Some(float) only if there's a non-None value
@@ -255,3 +256,5 @@ Or read these articles:
255
256
256
257
-[Python exceptions considered an anti-pattern](https://sobolevn.me/2019/02/python-exceptions-considered-an-antipattern)
257
258
-[Enforcing Single Responsibility Principle in Python](https://sobolevn.me/2019/03/enforcing-srp)
259
+
260
+
Do you have an article to submit? Feel free to open a pull request!
0 commit comments