Skip to content

Instantly share code, notes, and snippets.

View sloria's full-sized avatar

Steven Loria sloria

View GitHub Profile
sloria /
Last active August 14, 2022 13:26
Checklist for dropping Python 2 in my libraries
  • Add pyupgrade to .pre-commit-config.yaml.

If supporting py35, use --py3-plus instead of --py37-plus.

- repo:
  rev: ...latest version...
  - id: pyupgrade
 args: [--py37-plus]
sloria / daily-downloads.sql
Last active September 3, 2019 17:16
BigQuery scheduled query for daily marshmallow downloads
dls AS (
DATE_SUB(DATE(@run_time), INTERVAL 1 DAY) AS date,
file.project AS package, AS installer,
details.python AS python_version,
CAST(SPLIT(details.python, '.')[
(0)] AS string) AS python_major,
sloria / cloudSettings
Last active August 17, 2021 14:10
Visual Studio Code Settings Sync Gist
"""Dead simple ANSI coloring."""
import os
import sys
RED = 31
GREEN = 32
BOLD = 1
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
sloria /
Last active March 26, 2022 19:16 — forked from ergo/
Comparison between Marshmallow and Colander
import timeit
import uuid
import colander
import marshmallow
class BarList(colander.SequenceSchema):
item = colander.SchemaNode(
colander.Integer(), validator=colander.Range(min=1))

Keybase proof

I hereby claim:

  • I am sloria on github.
  • I am sloria ( on keybase.
  • I have a public key ASBdZO4CS0jaRD3dQZoIfStXBUcfe069S6IIlOJ1cC87nQo

To claim this, I am signing this object:

# Recorded with the doitlive recorder
#doitlive shell: /bin/bash
#doitlive prompt: sorin
class Foo:
# We can assign anything
f = Foo()
from copy import deepcopy
from marshmallow import Schema, fields
def PartialSchemaFactory(schema_cls):
schema = schema_cls(partial=True)
for field_name, field in schema.fields.items():
if isinstance(field, fields.Nested):
new_field = deepcopy(field)
new_field.schema.partial = True
sloria /
Last active April 16, 2019 15:45
import os
import re
import urlparse
import json as pyjson
NOTSET = object()
def shortcut(cast, **kwargs):
def method(self, var, default=NOTSET):