Pytest + Ruff + Mypy
There is a pytest-ruff plugin for
Pytest (a Python testing framework) that will automatically run
ruff format --check and ruff check as part of your test suite. The
pytest-mypy plugin does the same thing
for Mypy. These plugins are handy, but for some reason , the tests they generate
are exempted from the pytest -k ... logic. Normally, you can use -k to
select a subset of tests to run, but if you install one of the plugins
mentioned, that plugin’s tests run no matter what. This can slow you down if,
like me, you develop on a slow computer.
So, here’s what I use instead of pytest-ruff and pytest-mypy: A humble
test/test_qa.py file with three functions.
import subprocess
import sys
from pathlib import Path
import mypy.api
REPO_ROOT = Path(__file__).parent.parent
def test_mypy():
stdout, stderr, returncode = mypy.api.run([str(REPO_ROOT)])
sys.stdout.write(stdout)
sys.stderr.write(stderr)
assert returncode == 0
def test_ruff_format():
subprocess.run(
[sys.executable, "-m", "ruff", "format", "--check"],
cwd=REPO_ROOT,
check=True,
)
def test_ruff_lint():
subprocess.run(
[sys.executable, "-m", "ruff", "check"],
cwd=REPO_ROOT,
check=True,
)
(I run Mypy via its Python API instead of the command line to save a tiny bit of
subprocess.run() overhead, but it doesn’t make a massive difference.)
This gets you all the functionality of the plugins, but with two fewer
dependencies, and the -k flag works:
# Run tests for an in-progress feature and skip QA
pytest -k test_some_feature
# Run only the QA tests
pytest -k test_qa
# Run all tests
pytest
Person of the Year 2006
If you need a fun fact for a corporate icebreaker activity, you can always say, “I was Time magazine’s Person of the Year in 2006,” then stand around awkwardly waiting for someone to Google it.
The official announcement of “your” accomplishment makes for good reading in 2025. In tech circles, we often regard the early days of Web 2.0 as a time of naivety when we thought that letting anyone post on the internet would democratize media and unlock an era of creative expression. Of course, we know now that it isn’t so simple—that open platforms can amplify extreme views, for example, or serve as vectors for misinformation. But apparently we also knew this then, in the earliest days of YouTube and Facebook:
Web 2.0 harnesses the stupidity of crowds as well as its wisdom. Some of the comments on YouTube make you weep for the future of humanity just for the spelling alone, never mind the obscenity and the naked hatred.
But that’s what makes all this interesting. Web 2.0 is a massive social experiment, and like any experiment worth trying, it could fail.
Obviously, the course we chose twenty years ago led us to the world of today. But we didn’t select this path arbitrarily, or without regard for the challenges it would present; we examined the risks and decided the experiment was worth it.
I got a similar sense from reading Thomas Friedman’s The World is Flat (2005), which lays out a theory of globalization based on the convergence of technological development (the internet) and trade liberalization. Some of the passages feel quaint:
If there is a skilled person in Timbuktu, he will get work if he knows how to access the rest of the world, which is quite easy today. You can make a Web site and have an e-mail address and you are up and running. (Ch. 3)
(In the ebook, I commented, “Taxes? Immigration law?”) But elsewhere, Friedman anticipates critiques of globalization which have now become standard:
In the flat world, the balance of power between global companies and the individual communities in which they operate is tilting more and more in favor of the companies, many of them American-based. These companies command as much if not more power than many governments. (Ch. 13)
Not to mention “What the world has never witnessed is an old-style pandemic in a Wal-Mart world,” later on in the same chapter.
Urban Arts Career Pathways Takeover
My team at work recently got to host a Career Pathways Takeover at Urban Arts, a nonprofit based in New York that teaches programming, animation, and storytelling education to high schoolers to prepare them for success in college and beyond.
I was so impressed by the students’ thoughtfulness and engagement. We walked our group of Game Academy students through our team’s event planning process, and in less than an hour they put together a rock-solid plan for a community arts program to raise awareness about mental health issues, including how they’d use data to capture the event’s positive impact (where I fit in). I hope the vision can become a reality before long…!
Massive thanks the Urban Arts team for hosting us and for all that you do through the Game Academy.
Apply for CLS
This year’s application for Critical Language Scholarship from the US State Department is now open. (Thanks, group chat!)
CLS is a fully funded summer language immersion program for American undergraduate and graduate students. I strongly encourage any interested in learning one of the nine critical languages to apply. Some languages require prior language study; others accept beginners.
Feel free to email me if you are considering the CLS program or have questions about the experience. I completed CLS Korean in 2016 and have kept in touch with participants from lots of cohorts since then. Here is my advice post.
Good CLS blogs:
- Bethany Maz
- The Good Things Coming (Paula Zhang)
Python scripts
I cleaned up a few utility Python scripts for the GitHub:
- fetch_python_docs.py sets
up a local mirror of docs.python.org on
http://localhost:8004for offline reference. It can also provide and enable a systemd unit file, so you can run the script once, bookmark the local URL, and forget about it. - typography.py (which I mentioned
here) checks for ASCII typography
that can be better rendered as Unicode. For example, it recommends changing
the hyphen in the page range
278-81to an en dash. - dated.py applies my obnoxious filename convention to create a dated working copy of a file—useful when collaborating with people who aren’t comfortable with version control systems.