Skip to content

Instantly share code, notes, and snippets.

View sloria's full-sized avatar

Steven Loria sloria

View GitHub Profile
@sloria
sloria / dropping_py2.md
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: https://github.com/asottile/pyupgrade
  rev: ...latest version...
  hooks:
  - id: pyupgrade
 args: [--py37-plus]
@sloria
sloria / daily-downloads.sql
Last active September 3, 2019 17:16
BigQuery scheduled query for daily marshmallow downloads
WITH
dls AS (
SELECT
DATE_SUB(DATE(@run_time), INTERVAL 1 DAY) AS date,
file.project AS package,
details.installer.name AS installer,
details.python AS python_version,
CAST(SPLIT(details.python, '.')[
OFFSET
(0)] AS string) AS python_major,
@sloria
sloria / cloudSettings
Last active September 4, 2024 14:56
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-08-17T14:10:13.842Z","extensionVersion":"v3.4.3"}
"""Dead simple ANSI coloring."""
import os
import sys
RED = 31
GREEN = 32
YELLOW = 33
BOLD = 1
RESET_ALL = 0
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sloria
sloria / marshmallow_colander_bench.py
Last active March 26, 2022 19:16 — forked from ergo/marshmallow_colander_bench.py
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 (https://keybase.io/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
```python
class Foo:
pass
# 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
sloria / env.py
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):