Skip to content

Instantly share code, notes, and snippets.

Avatar

Steven Loria sloria

View GitHub Profile
@sloria
sloria / dropping_py2.md
Last active Feb 13, 2020
Checklist for dropping Python 2 in my libraries
View dropping_py2.md
  • Add pyupgrade to .pre-commit-config.yaml.

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

- repo: https://github.com/asottile/pyupgrade
  rev: ...latest version...
  hooks:
  - id: pyupgrade
    args: [--py36-plus]
@sloria
sloria / daily-downloads.sql
Last active Sep 3, 2019
BigQuery scheduled query for daily marshmallow downloads
View daily-downloads.sql
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 Jul 21, 2020
Visual Studio Code Settings Sync Gist
View cloudSettings
{"lastUpload":"2020-07-21T13:51:21.756Z","extensionVersion":"v3.4.3"}
View style.py
"""Dead simple ANSI coloring."""
import os
import sys
RED = 31
GREEN = 32
YELLOW = 33
BOLD = 1
RESET_ALL = 0
View Unknown fields.ipynb
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 Oct 1, 2018 — forked from ergo/marshmallow_colander_bench.py
Comparison between Marshmallow and Colander
View marshmallow_colander_bench.py
import timeit
import uuid
import colander
import marshmallow
class BarList(colander.SequenceSchema):
item = colander.SchemaNode(
colander.Integer(), validator=colander.Range(min=1))
View keybase.md

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:

View dil-slots.sh
# Recorded with the doitlive recorder
#doitlive shell: /bin/bash
#doitlive prompt: sorin
```python
class Foo:
pass
# We can assign anything
f = Foo()
View partial_schema_factory.py
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
View env.py
import os
import re
import urlparse
import json as pyjson
NOTSET = object()
def shortcut(cast, **kwargs):
def method(self, var, default=NOTSET):
You can’t perform that action at this time.