{"id":19399738,"url":"https://github.com/fbsamples/python-typing-tutorial","last_synced_at":"2025-07-24T03:03:31.854Z","repository":{"id":41821440,"uuid":"470777038","full_name":"fbsamples/python-typing-tutorial","owner":"fbsamples","description":"A sample Python project to demonstrate basic type checking concepts and best practices.","archived":false,"fork":false,"pushed_at":"2022-04-27T23:51:40.000Z","size":156,"stargazers_count":7,"open_issues_count":0,"forks_count":10,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-04-03T00:41:19.411Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fbsamples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-16T22:58:51.000Z","updated_at":"2025-02-12T08:13:48.000Z","dependencies_parsed_at":"2022-08-11T18:31:53.916Z","dependency_job_id":null,"html_url":"https://github.com/fbsamples/python-typing-tutorial","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fbsamples%2Fpython-typing-tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fbsamples%2Fpython-typing-tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fbsamples%2Fpython-typing-tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fbsamples%2Fpython-typing-tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fbsamples","download_url":"https://codeload.github.com/fbsamples/python-typing-tutorial/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250578403,"owners_count":21453307,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T11:11:02.793Z","updated_at":"2025-04-24T06:32:10.482Z","avatar_url":"https://github.com/fbsamples.png","language":"Python","readme":"# python-typing-tutorial\n\nA sample Python project to demonstrate basic type checking concepts and best practices.\n\nThe four sample projects included correspond to each section of the PyCon 2022 \"Python Types for Fun and Profit\" tutorial.\n\n1. `introduction_exercises`: Annotating examples of basic data structures.\n2. `demo_project`: Getting-started demo for setting up Pyre locally in a new project.\n3. `gradual_typing_project`: Example project for applying type checking modes and other approaches to gradually increasing type coverage.\n4. `typing_pattern_exercises`: More detailed and advanced Python patterns to practice expressing dynamic behavior in the type system\n\n## Resources\n\n[Tutorial Handout Sheet](https://docs.google.com/document/d/15QZo9Sj_9RQJ79QdJdafRGITjU72jlQbMfQotnTVETo/edit?usp=sharing)\n\n[Tutorial Slides](https://docs.google.com/presentation/d/1fs-BRJezX7pJMqbJ9__nJn64zaReEX-_nvR7Tn-Syac/edit)\n\n[Tutorial Slides (PDF)](https://drive.google.com/file/d/1Me1E6hCVb-28Ka1KpoNorSyZs-73-nRY/view?usp=sharing)\n\n## Setting up\n\nYou'll want a python 3.10 environment and `watchman`, along with the\nlatest version of the `pyre-check` package.\n\nIf you run into trouble, an alternative way to get started is to sign up\nfor `repl.it` (you can sign in through github) and use\n[the PyrePycon2022 repl](https://replit.com/@stroxler/PyrePycon2022-nix?v=1)\nto try out Pyre on Linux in the browser.\n\n### Installing watchman\n\n[Watchman](https://facebook.github.io/watchman/) is a file monitoring service that records when files change. It is required to run a type checker server that delivers fast, incremental results based on file updates. Without it, you will need to run a full `pyre check` that type checks the entire project each time and cannot use editor integration.\n\n#### On MacOS\n\n```bash\nbrew install watchman\n```\n\n#### On Ubuntu\n\n```bash\nsudo apt-get update\n\nsudo apt-get -y watchman\n```\n\n\n### Installing Python 3.10\n\nHow exactly to get the latest Python release varies system to system,\nand you may already use a solution such as `conda`.\n\nWe have instructions for using `pyenv` for this, but you're welcome\nto use any other approach you know.\n\n#### On MacOS\n\n```bash\nbrew install pyenv\n\necho '\nexport PYENV_ROOT=\"$HOME/.pyenv\"\nexport PATH=\"$PYENV_ROOT/bin:$PATH\"\nexport PATH=\"$PYENV_ROOT/shims:$PATH\"\neval \"$(pyenv init -)\"\n' \u003e\u003e ~/.profile\n\n. ~/.profile\n\npyenv install 3.10.4\n```\n\n\n#### On Ubuntu\n\n```bash\nsudo apt-get update\n\nsudo apt-get install -y \\\n    git make build-essential libssl-dev zlib1g-dev libbz2-dev \\\n    libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \\\n    libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev\n\ngit clone https://github.com/pyenv/pyenv.git ~/.pyenv\n\necho '\nexport PYENV_ROOT=\"$HOME/.pyenv\"\nexport PATH=\"$PYENV_ROOT/bin:$PATH\"\nexport PATH=\"$PYENV_ROOT/shims:$PATH\"\neval \"$(pyenv init -)\"\n' \u003e\u003e ~/.profile\n\n. ~/.profile\n\npyenv install 3.10.4\n```\n\n#### On windows:\n\nWe recommend using the Windows Subsystem for Linux:\n- Open a windows console in administrator mode\n- Run `wsl --install -d Ubuntu-20.04`\n- Restart your computer\n- When it restarts, the `Ubuntu-20.04` application should open\n  - Create a user. We recommend reusing the user from your\n    windows install, but you could create a user just for pycon\n  - Now, follow the `Ubuntu` instructions above.\n\nFrom this point forward, to work with pyre you can:\n- Open the `Ubuntu-20.04` application\n- Do any terminal actions (like running `pyre`) you want from\n  that terminal session.\n- In order to use native tools, like your (VSCode editor) with\n  files here, run `explorer.exe \u003cname_of_a_directory\u003e`\n  - This will open up the directory in windows explorer.\n  - From there you can do things like open files in VSCode.\n\n\n### Setting up pyre-check in a venv\n\n\nYou can clone this repo in one of two ways:\n- First fork it to your user using the \"Fork\" button, and then\n  clone from that repository\n- Or, if you don't care about playing with github, just clone directly:\n  `git clone https://github.com/fbsamples/python-typing-tutorial.git`\n\nThen, set it up to use Python 3.10.4:\n```\ncd python-typing-tutorial\n\nPYENV_VERSION=3.10.4 python -m venv pyre-venv\n. pyre-venv/bin/activate\n\npip install pyre-check\n```\n\nYou can make sure it works by running\n```\ncd gradual_typing_project\npyre init \u003c\u003c\u003c '\n'\npyre\n```\nwhich should spit out:\n```\n+ No type errors found\n```\n\n## Contributing\n\nSee the [CONTRIBUTING](CONTRIBUTING.md) file for how to help out.\n\n## License\n\npython-typing-tutorial is MIT licensed, as found in the LICENSE file.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffbsamples%2Fpython-typing-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffbsamples%2Fpython-typing-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffbsamples%2Fpython-typing-tutorial/lists"}