Arrange files like this:
apple/
__init__.py
apple.py
tests/
test_everything.py
diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py | |
index 0288d7a54..54d5956d4 100644 | |
--- a/src/_pytest/_code/code.py | |
+++ b/src/_pytest/_code/code.py | |
@@ -486,9 +486,7 @@ class ExceptionInfo(Generic[E]): | |
.. versionadded:: 7.4 | |
""" | |
- assert ( | |
- exception.__traceback__ |
""" | |
Change the "default" flags for files in a project, so new files will require full type annotations. | |
If a file has no flags, it adds "allow-untyped-defs". | |
If a file already has "disallow-untyped-defs", that flag is removed. | |
Together with this script, one should update the mypy.ini file of a project: | |
[mypy.app.*] | |
disallow_untyped_defs = true |
Arrange files like this:
apple/
__init__.py
apple.py
tests/
test_everything.py
from pathlib import Path | |
import attr | |
from sqlalchemy import Column | |
from sqlalchemy import create_engine | |
from sqlalchemy import ForeignKey | |
from sqlalchemy import Integer | |
from sqlalchemy import MetaData | |
from sqlalchemy import String | |
from sqlalchemy import Table |
# from: https://doc.qt.io/qt-5/qtcharts-nesteddonuts-example.html | |
import functools | |
import random | |
from PyQt5.QtChart import * | |
from PyQt5.QtGui import * | |
from PyQt5.QtCore import * | |
from PyQt5.QtWidgets import * | |
class Widget(QWidget): |
Seed: 173015 | |
0 X 1 | |
1 X 1 | |
0 X 2 | |
1 X 1 | |
2 X 1 | |
1 X 1 | |
1 X 3 | |
2 X 2 |
def GetFields(): | |
fields = dict( | |
tabs=dict( | |
_id='tabs', | |
caption='', | |
caption_cmd='', | |
caption_color_expr='', | |
caption_horizontal_size_policy='Preferred', | |
caption_vertical_size_policy='Fixed', | |
cmd='', |
Com relação à type-hints, eu também sou bastante fã.
Type hints, quando rodados junto com um type checker como o mypy, trazem muitas vantagens:
Com certeza não substitui a documentação escrita, mas colocar type hints realmente facilita, pois além de não depender das docstrings, ainda temos a ferramenta checando para você, evitando que ela fica desetualizada.
Eu já vi muitas e muitas vezes (e escrevi também) documentação que até estava correta inicialmente, mas depois de um tempo ficou desatualizada. Por exemplo, dizer que um método retorna um dict
de str
-> int
, mas devido à algum refactoring ele às vezes retornava um valor str
(ao invés de int
), quebrando o cliente. Aqui o type checker vai detectar o problema imediatamente.
""" | |
Verbatim translation of the RangeSlider class from: | |
https://github.com/ThisIsClark/Qt-RangeSlider/tree/b3e381fd383aa5b02e78caff9a42fc5f4aab63e6 | |
This is a verbatim translation, without any improvements that could be | |
made to the code, such as using max()/min() in a few places, interval comparisons | |
(`0 < x < 10` instead of `x > 0 and x < 10`), etc. | |
The intent is to keep it as close as the original as possible in case we want |