Skip to content

Commit

Permalink
Merge pull request #8 from austinscchiang/static_typechecking_support
Browse files Browse the repository at this point in the history
[nbapagerank] add static typechecking (mypy) and linting (black)
  • Loading branch information
austinscchiang committed Sep 29, 2020
2 parents 339f320 + f753479 commit f18f962
Show file tree
Hide file tree
Showing 2,137 changed files with 269,430 additions and 29 deletions.
10 changes: 10 additions & 0 deletions env/bin/black
@@ -0,0 +1,10 @@
#!/Users/austinscchiang/Documents/nba_pagerank/env/bin/python3
# -*- coding: utf-8 -*-
import re
import sys

from black import patched_main

if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(patched_main())
10 changes: 10 additions & 0 deletions env/bin/black-primer
@@ -0,0 +1,10 @@
#!/Users/austinscchiang/Documents/nba_pagerank/env/bin/python3
# -*- coding: utf-8 -*-
import re
import sys

from black_primer.cli import main

if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())
10 changes: 10 additions & 0 deletions env/bin/blackd
@@ -0,0 +1,10 @@
#!/Users/austinscchiang/Documents/nba_pagerank/env/bin/python3
# -*- coding: utf-8 -*-
import re
import sys

from blackd import patched_main

if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(patched_main())
10 changes: 10 additions & 0 deletions env/bin/dmypy
@@ -0,0 +1,10 @@
#!/Users/austinscchiang/Documents/nba_pagerank/env/bin/python3
# -*- coding: utf-8 -*-
import re
import sys

from mypy.dmypy.client import console_entry

if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(console_entry())
10 changes: 10 additions & 0 deletions env/bin/mypy
@@ -0,0 +1,10 @@
#!/Users/austinscchiang/Documents/nba_pagerank/env/bin/python3
# -*- coding: utf-8 -*-
import re
import sys

from mypy.__main__ import console_entry

if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(console_entry())
55 changes: 55 additions & 0 deletions env/bin/mypyc
@@ -0,0 +1,55 @@
#!/Users/austinscchiang/Documents/nba_pagerank/env/bin/python3
"""Mypyc command-line tool.
Usage:
$ mypyc foo.py [...]
$ python3 -c 'import foo' # Uses compiled 'foo'
This is just a thin wrapper that generates a setup.py file that uses
mypycify, suitable for prototyping and testing.
"""

import os
import os.path
import subprocess
import sys
import tempfile
import time

base_path = os.path.join(os.path.dirname(__file__), '..')

setup_format = """\
from distutils.core import setup
from mypyc.build import mypycify
setup(name='mypyc_output',
ext_modules=mypycify({}, opt_level="{}"),
)
"""

def main() -> None:
build_dir = 'build' # can this be overridden??
try:
os.mkdir(build_dir)
except FileExistsError:
pass

opt_level = os.getenv("MYPYC_OPT_LEVEL", '3')

setup_file = os.path.join(build_dir, 'setup.py')
with open(setup_file, 'w') as f:
f.write(setup_format.format(sys.argv[1:], opt_level))

# We don't use run_setup (like we do in the test suite) because it throws
# away the error code from distutils, and we don't care about the slight
# performance loss here.
env = os.environ.copy()
base_path = os.path.join(os.path.dirname(__file__), '..')
env['PYTHONPATH'] = base_path + os.pathsep + env.get('PYTHONPATH', '')
cmd = subprocess.run([sys.executable, setup_file, 'build_ext', '--inplace'], env=env)
sys.exit(cmd.returncode)

if __name__ == '__main__':
main()
10 changes: 10 additions & 0 deletions env/bin/stubgen
@@ -0,0 +1,10 @@
#!/Users/austinscchiang/Documents/nba_pagerank/env/bin/python3
# -*- coding: utf-8 -*-
import re
import sys

from mypy.stubgen import main

if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())
10 changes: 10 additions & 0 deletions env/bin/stubtest
@@ -0,0 +1,10 @@
#!/Users/austinscchiang/Documents/nba_pagerank/env/bin/python3
# -*- coding: utf-8 -*-
import re
import sys

from mypy.stubtest import main

if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions env/lib/python3.7/site-packages/_black_version.py
@@ -0,0 +1 @@
version = "20.8b1"
@@ -0,0 +1 @@
pip
@@ -0,0 +1,23 @@
# This is the MIT license

Copyright (c) 2010 ActiveState Software Inc.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 comments on commit f18f962

Please sign in to comment.