This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Example of a functional-ish centric design and encoding logic in rules. | |
This uses determination of a leap year as an simple example. | |
This approach could be used in more involved cases to encode business logic. | |
""" | |
import operator as op |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Common core utils are too small that don't warrant creating a package | |
from argparse import ArgumentParser, Namespace, ArgumentDefaultsHelpFormatter | |
import csv | |
import functools | |
import logging | |
import sys | |
from typing import Callable as F | |
from typing import List, TypeVar, Type, Iterator | |
from pydantic import BaseModel |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from collections import deque | |
def to_tail(it, max_items): | |
""" | |
https://twitter.com/Wildvasa/status/1207383049387810816 | |
Get the last N elements from an iterable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
from collections import Counter | |
# https://docs.python.org/3.8/library/collections.html?highlight=counter#collections.Counter | |
# Example of using collections.Counter to count item | |
# https://twitter.com/DavidMezzetti/status/1204493772274438151 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
metaflow/package.py:24:4: W0102: Dangerous default value DEFAULT_SUFFIXES (builtins.list) as argument (dangerous-default-value) | |
metaflow/runtime.py:431:4: W0102: Dangerous default value [] as argument (dangerous-default-value) | |
metaflow/flowspec.py:130:4: W0102: Dangerous default value {} as argument (dangerous-default-value) | |
metaflow/flowspec.py:130:4: W0102: Dangerous default value [] as argument (dangerous-default-value) | |
metaflow/flowspec.py:256:4: W0102: Dangerous default value [] as argument (dangerous-default-value) | |
metaflow/pylint_wrapper.py:26:4: W0102: Dangerous default value [] as argument (dangerous-default-value) | |
metaflow/plugins/aws/batch/batch.py:96:4: W0102: Dangerous default value {} as argument (dangerous-default-value) | |
metaflow/plugins/aws/batch/batch.py:96:4: W0102: Dangerous default value {} as argument (dangerous-default-value) | |
metaflow/metadata/service.py:40:4: W0102: Dangerous default value [] as argument (dangerous-default-value) | |
metaflow/metadata/service.py:40:4: W0102: Dangerous defau |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
"""Output from mypy 0.711 | |
typeddict_pad.py:28: error: Module 'typing' has no attribute 'TypedDict'; maybe "_TypedDict"? | |
typeddict_pad.py:28: error: Name 'TypedDict' already defined (possibly by an import) | |
typeddict_pad.py:90: error: Unsupported operand types for + ("str" and "int") | |
typeddict_pad.py:107: error: Argument 2 has incompatible type "int"; expected "str" | |
typeddict_pad.py:110: error: Unsupported operand types for + ("int" and "str") | |
typeddict_pad.py:118: error: "Movie" has no attribute "clear" | |
typeddict_pad.py:128: error: Argument 1 to "update" of "TypedDict" has incompatible type "Dict[str, object]"; expected "TypedDict({'name'?: str, 'year'?: int})" | |
typeddict_pad.py:137: error: Argument 1 to "update" of "TypedDict" has incompatible type "Movie"; expected "TypedDict({'name'?: str, 'year'?: int})" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
https://twitter.com/AlSweigart/status/1170907280285417473 | |
Refactored from https://pastebin.com/raw/hU1m440m by Al Sweigart [email protected] | |
""" | |
import re | |
import operator as op | |
import sys | |
from typing import NamedTuple, List, Any |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Requires Python 3.8 | |
Expanding on a Tweet from RH using walrus and f-strings | |
https://twitter.com/raymondh/status/1153085050650423296 | |
""" | |
import logging |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies: | |
- panel>=0.6.0 | |
- holoviews | |
- hvplot | |
- param | |
- matplotlib | |
- scipy | |
- conda-forge::altair | |
- conda-forge::plotly | |
- conda-forge::vtk=8.1.1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.