#320: The Bug Is In The JavaScript
Published Tue, Jan 24, 2023,
recorded Tue, Jan 24, 2023
About the show
Sponsored by us! Support our work through:
Connect with the hosts
- Michael: @mkennedy@fosstodon.org
- Brian: @brianokken@fosstodon.org
- Show: @pythonbytes@fosstodon.org
Join us on YouTube at pythonbytes.fm/stream/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: markdown-it-py
- Yes. another markdown parser.
- Rich recently switched markdown parsers, from
commonmark
tomarkdown-it-py
. - Let’s look at those a bit.
Michael #2: Sketch
- via Jake Firman
- Sketch is an AI code-writing assistant for pandas users that understands the context of your data
- A Natural Language interface that successfully navigates many tasks in the data stack landscape.
- Data Cataloging:
- General tagging (eg. PII identification)
- Metadata generation (names and descriptions)
- Data Engineering:
- Data cleaning and masking (compliance)
- Derived feature creation and extraction
- Data Analysis:
- Data questions
- Data visualization
- Data Cataloging:
- Watch the video on the GitHub page for a quick intro
Brian #3: Fixing Circular Imports in Python with Protocol
- Built on Subclassing in Python Redux from Hynek
- We covered this in the summer of 2021, episode 240
- However, I re-read it recently due to a typing problem
- Problem is when an object passes itself to another module to be called later.
- This is common in many design patterns, including just normal callback functions.
- Normally not a problem with Python, due to duck typing.
- But with type hints, suddenly it seems like both modules need types from the other.
- So how do you have two modules use types from each other without a circular import.
- Hynek produces two options
- Abstract Data Types, aka Interfaces, using the
abc
module- Requires a third interface class
- Structural subtyping with
Protocol
- This is what I think I’ll use more often and I’m kinda in love with it now that I understand it.
- Still has a third type, but one of the modules doesn’t have to know about it.
- "Structural Subtyping : Structural subtyping is duck typing for types: if your class fulfills the constraints of a
[Protocol](https://docs.python.org/3/library/typing.html#typing.Protocol)
, it’s automatically considered a subtype of it. Therefore, a class can implement manyProtocol
s from all kinds of packages without knowing about them!”
- Abstract Data Types, aka Interfaces, using the
- The Fixing Circular Imports in Python with Protocol article walks through one example of two classes talking with each other, typing, circular imports, and fixing them with Protocol
Michael #4: unrepl
- via/by Ruud van der Ham
We’ve seen the code samples:
>>> board = [] >>> for i in range(3): ... row = ['_'] * 3 ... board.append(row) ... >>> board [['_', '_', '_'], ['_', '_', '_'], ['_', '_', '_']] >>> board\[2\][0] = 'X' >>> board [['_', '_', '_'], ['_', '_', '_'], ['X', '_', '_']]
But you cannot really run this code. You can’t paste it into a REPL yourself nor can you put it into a .py file.
- So you unrepl it: Copying the above code to the clipboard and run unrepl.
- Paste the result and now you can.
- Unrepl can be used as a command line tool but also as a module.
- The REPL functionality of underscore (_) to get access to the last value is also supported.
Extras
Michael:
- You'll want to update your git ASAP.
- Get course releases at Talk Python via RSS
- Gist for using Turnstile with Python + Pydantic
Joke: there's a bug in the js
- You’ve checked all your database indexes,
- You’ve tuned all your API hooks,
- You’re starting to think
- That you might need a drink,
- Because there’s only one place left to look:
- …
- There must be a bug in the javascript
- Because everything else was built properly
- But the frontend’s a pile of crap ;)