Skip to content

Instantly share code, notes, and snippets.

View nicoddemus's full-sized avatar

Bruno Oliveira nicoddemus

View GitHub Profile
@nicoddemus
nicoddemus / foo.py
Last active March 17, 2021 18:07
mypy slow with nested dict call
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='',
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
@nicoddemus
nicoddemus / update-mypy-flags.py
Last active May 16, 2024 12:26
Apply allow-untyped-defs
"""
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
@nicoddemus
nicoddemus / ruff.diff
Created October 24, 2023 18:01
Trying out ruff formatter on pytest - 7 files modifed
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__