Skip to content

Instantly share code, notes, and snippets.

@Michael0x2a
Michael0x2a / convert_stubs.py
Created April 11, 2019 19:27
A quick and dirty script to make stub files use variable annotations
"""
convert_stubs.py
Modifies stub files to use variable annotations instead of type comments.
To run, pass in a path to the directory containing stubs. This script will
recursively traverse it and modify all .pyi files:
$ python3 convert_stubs.py path/to/stubs
_________________________ testTypeTypeComparisonWorks _________________________
[gw2] win32 -- Python 3.6.3 c:\python3.6\python.exe
data: C:\Users\Michael\Dropbox\Projects\Code\Programs\mypy\mypy\test-data\unit\check-classes.test:3251:
SystemExit: 1
---------------------------- Captured stdout call -----------------------------
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "<string>", line 8, in <module>
File "c:\python3.6\lib\site-packages\execnet\gateway_base.py", line 1534, in serve
SlaveGateway(io=io, id=id, _startcount=2).serve()
__________________________ testMetaclassOpAccessAny ___________________________
[gw1] win32 -- Python 3.6.3 c:\python3.6\python.exe
data: C:\Users\Michael\Dropbox\Projects\Code\Programs\mypy\mypy\test-data\unit\pythoneval.test:1206:
..\..\..\..\Dropbox\Projects\Code\Programs\mypy\mypy\mypy\test\testpythoneval.py:42: in run_case
test_python_evaluation(testcase, os.path.join(self.cache_dir.name, '.mypy_cache'))
..\..\..\..\Dropbox\Projects\Code\Programs\mypy\mypy\mypy\test\testpythoneval.py:97: in test_python_ev
aluation
testcase.file, testcase.line))
..\..\..\..\Dropbox\Projects\Code\Programs\mypy\mypy\mypy\test\helpers.py:111: in assert_string_arrays
_equal
usage: mypy [-h] [-v] [-V] [more options; see below]
[-m MODULE] [-p PACKAGE] [-c PROGRAM_TEXT] [files ...]
Mypy is a program that will type check your Python code.
Pass in any files or folders you want to type check. Mypy will
recursively traverse any provided folders to find .py files:
$ mypy my_program.py my_src_folder
@Michael0x2a
Michael0x2a / gist:36c5948a7ea571b722686226639b0859
Last active June 8, 2018 02:49
Proposed mypy '--help' output
usage: mypy [-h] [-v] [-V] [--config-file CONFIG_FILE] [--warn-unused-configs]
[--ignore-missing-imports]
[--follow-imports {normal,silent,skip,error}]
[--python-executable EXECUTABLE] [--no-site-packages]
[--python-version x.y] [-2] [--platform PLATFORM]
[--always-true NAME] [--always-false NAME]
[--disallow-any-unimported] [--disallow-any-expr]
[--disallow-any-decorated] [--disallow-any-explicit]
[--disallow-any-generics] [--disallow-untyped-calls]
[--disallow-untyped-defs] [--disallow-incomplete-defs]
from typing import overload, Sequence, Union, NewType
from mypy_extensions import NoReturn
# by convention, underlying type should not be 'str'
ArgList = NewType('ArgList', Sequence[str])
@overload
def make_arglist(x: str) -> NoReturn: ...
@overload
In Python 3.6.1 but not 3.5.0
AsyncGenerator
AsyncIterable
AsyncIterator
Awaitable
CT_co
ChainMap
ClassVar
Collection
ContextManager
@Michael0x2a
Michael0x2a / pgfsys-luatex.def
Created April 1, 2017 04:23
pgfsys-luatex.def
% Copyright 2006 by Till Tantau
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.
\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/systemlayer/pgfsys-luatex.def,v 1.35 2014/10/11 09:23:31 vibrovski Exp $
@Michael0x2a
Michael0x2a / removeMatchingLeaves-overview.md
Last active December 7, 2016 06:08
removeMatchingLeaves-overview.md

removeMatchingLeaves

Overview

In section, we didn't quite have enough time to go over the [removeMatchingLeaves][0] problem. If you haven't already, I would go visit that link and read through the spec to make sure you understand what that problem is asking you.

To summarize, this problem is asking us to add a method to an IntTree. This method must accept another tree as a parameter, and must modify the current tree by removing all "matching leaves".

@Michael0x2a
Michael0x2a / cse-143-16au-study-guide.md
Last active February 19, 2024 04:50
CSE 143 16au study guide

CSE 143 16au study guide

How to study

Programming, to a large extent, is about applied problem-solving, and is not about memorization. This means that the best way to prep for programming exams isn't to sit down and read through the slides -- it's by solving a lot of problems.

As a result, I strongly recommend you do the following when preparing: