Skip to content

Instantly share code, notes, and snippets.

View nicoddemus's full-sized avatar

Bruno Oliveira nicoddemus

View GitHub Profile
@nicoddemus
nicoddemus / failures.txt
Created October 25, 2017 23:28
py.path\test_svnwc.py failures on Windows
[00:00:00] Build started
[00:00:00] git clone -q https://github.com/pytest-dev/py.git C:\projects\py
[00:00:11] git fetch -q origin +refs/pull/157/merge:
[00:00:12] git checkout -qf FETCH_HEAD
[00:00:12] Running Install scripts
[00:00:12] echo Installed Pythons
[00:00:12] Installed Pythons
[00:00:12] dir c:\Python*
[00:00:12] Volume in drive C is Windows
[00:00:12] Volume Serial Number is D4AB-4044

Keybase proof

I hereby claim:

  • I am nicoddemus on github.
  • I am nicoddemus (https://keybase.io/nicoddemus) on keybase.
  • I have a public key ASC8AmwlFA5-gi0XY_kKS7Ahny_JW1sEAA8lXL5rU7jMdgo

To claim this, I am signing this object:

sip/PyQt5/QtCore/qsettings.sip
sip/PyQt5/QtBluetooth/qbluetoothaddress.sip
sip/PyQt5/QtWidgets/qscrollarea.sip
sip/PyQt5/QtWidgets/qgesturerecognizer.sip
sip/PyQt5/QtLocation/qgeoroutingmanagerengine.sip
sip/PyQt5/QtWidgets/qtabwidget.sip
sip/PyQt5/QtNetwork/qnetworkaccessmanager.sip
sip/PyQt5/QtLocation/qgeorouterequest.sip
Lib/site-packages/PyQt5/Enginio.pyi
sip/PyQt5/QtGui/qvector4d.sip
@nicoddemus
nicoddemus / output
Created January 22, 2018 18:42
pyinstaller output: debugging why QtQuick is being considered for inclusion
['pyinstaller', '--clean', '--noconfirm', '--log-level=DEBUG', 'w:/ws/Alfasim/Projects/alfasim/alfasim_gui/package/pyinstaller\\ALFASim.spec']
415 INFO: PyInstaller: 3.4.dev0+gfb56676a
415 INFO: Python: 3.6.4
415 INFO: Platform: Windows-10-10.0.16299-SP0
415 DEBUG: Testing for UPX ...
431 INFO: UPX is not available.
431 INFO: Removing temporary files and cleaning cache in C:\Users\bruno\AppData\Roaming\pyinstaller
435 DEBUG: script: w:\ws\Alfasim\Projects\alfasim\alfasim_gui\source\python\main.py
435 DEBUG: script: w:\ws\Alfasim\Projects\alfasim\alfasim_gui\source\python\alfasim_gui\required_imports_generated.py
@nicoddemus
nicoddemus / conftest.py
Created March 7, 2018 23:20
Obtain parametrized names and values of a failed parametrized test
import pytest
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item):
outcome = yield
report = outcome.get_result()
parametrize_mark = item.get_marker('parametrize')
if report.failed and parametrize_mark:
# @pytest.mark.parametrize can accept "x, y" or ["x", "y"] as argument names
@nicoddemus
nicoddemus / out.diff
Created May 24, 2018 00:33
black on pytest/testing
diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py
index c2eed419..ad709c9b 100644
--- a/testing/acceptance_test.py
+++ b/testing/acceptance_test.py
@@ -595,6 +595,7 @@ class TestInvocationVariants(object):
cur = os.environ.get("PYTHONPATH")
if cur:
return str(what) + os.pathsep + cur
+
return what
@nicoddemus
nicoddemus / sqlalchemy-scalar.py
Last active March 26, 2019 16:10
Quick example of using class-decorators to declare compound columns
from sqlalchemy import create_engine
from sqlalchemy import Column, Float, Integer, String
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine('sqlite:///:memory:', echo=True)
Base = declarative_base()
class ScalarField:
pass
@nicoddemus
nicoddemus / pluggy-0.11.1-benchs.md
Created May 17, 2019 12:02
pluggy benchmarks v0.11.1 vs master

0.11.1

------------------------------------------------------------------------------------------------------------------ benchmark: 8 tests -----------------------------------------------------------------------------------------------------------------
Name (time in us)                                                              Min                   Max                Mean              StdDev              Median                IQR            Outliers  OPS (Kops/s)            Rounds  Iterations
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_hook_and_wrappers_speed[hooks=10-wrappers=10-_multicall]              34.7022 (1.0)        160.4266 (1.0)       38.0200 (1.0)       10.0398 (1.0)       35.2711 (1.0)       0.5689 (1.0)      572;1025
26.3019 (1.0)        6921           1
test_hook_and_wrappers_s
"""
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

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:

  1. Documentação.

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.