typeshed
DefinitelyTyped
Our great sponsors
typeshed | DefinitelyTyped | |
---|---|---|
24 | 158 | |
4,017 | 46,896 | |
2.2% | 0.9% | |
9.9 | 10.0 | |
1 day ago | about 5 hours ago | |
Python | TypeScript | |
GNU General Public License v3.0 or later | GNU General Public License v3.0 or later |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
typeshed
-
Ask HN: Will we see a TypeScript for Python?
https://github.com/python/typeshed is Python's equivalent of DefinitelyTyped. I'm not 100% sure why it's not more of a popular thing the way DefinitelyTyped is; I think there might, to some extent, be different attitudes around the appropriateness of having third-party typings for packages, when the actual maintainer of the package isn't interested in providing first-party ones.
-
Why Type Hinting Sucks!
https://github.com/python/mypy same with typeshed https://github.com/python/typeshed
-
When the client's management is happy but their dev team is a pain
Here's the tensorflow type stubs on typeshed. https://github.com/python/typeshed/tree/main/stubs/tensorflow
-
Ruby 3.2’s YJIT is Production-Ready
Python's type hints are definitely an improvement and they're getting better all the time, but they're still frustrating to use at anything approaching the edge. I long for something as elegant and functional as TypeScript.
One hurdle I've stumbled over recently is the question "what is a type?", the answer can be surprising. Unions, for example, are types but not `Type`s. A function that takes an argument of type `Type` will not accept a Union. So if you want to write a function that effectively "casts" a parameter to a specified type, you can't. The best you can do is have an overload that accepts `Type` and does an actual cast, and then another that just turns it into `Any`. This is, in fact, how the standard library types its `cast` function [1]. The argument I've seen for the current behavior is that `Type` describes anything that can be passed to isinstance, but that's not a satisfying answer. Even then, `Union` can be passed to isinstance and still does not work with `Type`. Talk currently is to introduce a new kind of type called `TypeForm` or something to address this, which is certainly an improvement over nothing, but still feels like technical debt.
[1]: https://github.com/python/typeshed/blob/main/stdlib/typing.p...
-
GitHub stars won't pay your rent
>Ultimately if you care enough about Fody to spend over a hundred dollars worth of your time contributing to it, you probably care enough about Fody to drop them three dollars.
No, I really don't.
https://github.com/keepassxreboot/keepassxc/pull/8500 - I was randomly reading keepassxc's manpage and spotted a curious option, spent some time spelunking through the code and history to discover that it was an outdated option, sent a PR.
https://github.com/python/typeshed/pull/8617 - I converted one of the scripts I use in my DE from shell to Python, saw that VSCode has this new fancy typing support for Python, quickly found a basic bug in the type definitions for the os module, tested a fix locally, sent a PR.
https://gitlab.gnome.org/GNOME/gtk/-/issues/5250 - I found an issue with copy-paste on my phone, investigated it all the way through to the GTK stack, found the commits that introduced the issue, created a distro patch for it while discussing it with GTK upstream.
https://gitlab.alpinelinux.org/alpine/aports/-/merge_request... - I noticed that gnome-passwordsafe crashes some times, debugged it to discover that it was missing a dependency, sent a PR to the distro package to update the dependencies.
etc etc. I've made lots of fixes like these. I have no interest in paying for each and every one of them. The projects are all better off for fixes like mine and gatekeeping them on payment would've been nothing but their loss.
-
Using Mypy in Production
You have to do handling like that in other languages like TypeScript anyway.
Painpoint with type annotations:
- not being able to reuse "shapes" of data: TypedDict, NamedTuple, dataclasses.dataclass, and soon kwargs (PEP 692 [1]) all have named, typed fields now. You have to
- Since there's no generic "shape" structure that works across data types, there isn't a way to load up a JSON / YAML / TOML into a dictionary, upcast it via a `TypedGuard`, and pass it into a TypedDict / NamedTuple / Dataclass. dataclasses.asdict() or dataclasses.astuple() return naive / untyped tuples and dicts. Also the factory functions will not work with TypedDict or NamedTuple, respectively, even if you duplicate the fields by hand. See my post here: https://github.com/python/typeshed/issues/8580
- Standard library doesn't have runtime validation (e.g. pydantic / https://github.com/pydantic/pydantic).
- pytest fixtures are hard.
- Django is hard. PEP 681 may not be a saving grace either. [3]
-
Welcome to hassle free coding
The whole Python Standard Library: https://github.com/python/typeshed/tree/master/stdlib
-
Python’s “Type Hints” are a bit of a disappointment to me
https://github.com/python/typeshed also provides community maintained stub packages for packages that are lacking upstream type hints
-
Java vs python is debatable 🤔
Using any linter + type checker solves many of your problems. Just annotate your types (possibly using the typing module below Python 3.10), run flake8 and mypy and you're fine. Also c.f. PEP-484 for how and why it was done like this. And use typeshed stubs for untyped libs, most major libraries have typings in there ;)
-
Why Static Languages Suffer From Complexity
Do you mean declaration files (*.d.ts) and DefinitelyTyped? Python has equivalents of those in type stubs (*.pyi) and typeshed.
DefinitelyTyped
-
5 Resources Each TypeScript Developer Should Know About
View on GitHub
-
Show HN: OpenAPI DevTools – Chrome ext. that generates an API spec as you browse
Do you mean the devtool protocol[1]? I didn't follow the space so have no knowledge on it. On the other hand there seem to be a polyfilled API on chrome.devtools.network.Request which OP's extension uses extensively https://github.com/DefinitelyTyped/DefinitelyTyped/blob/mast...
Firefox maintain a library for unified extension API https://github.com/mozilla/webextension-polyfill
Their type definition for HAR request isn't exported https://github.com/DefinitelyTyped/DefinitelyTyped/blob/mast...
-
Typescript - Union types e type guards
type NumberOrString = number | string; type Status = "idle" | "loading" | "success" | "failure" // React useState, can receive a value or a function as parameter to serve as initial value. // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/a03856975a17eba524739676affbf70ac4078176/types/react/v17/index.d.ts#L920 function useState(initialState: S | (() => S)): [S, Dispatch>];
- If you ever get called out for using long type names, remember this exists
-
Declaring JSX types in TypeScript 5.1
The TypeScript pull request was merged, so Sebastian (who helps maintain the React type definitions) exercised new powers in this pull request to the DefinitelyTyped repository for the React type definitions. At the time of writing, this pull request is still open, but once merged and shipped the React community we will feel its benefits.
-
DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES[keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES]
there is an open issue: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/61616
-
Challenges and Confusion in Learning React Native
You can find more information here: https://github.com/DefinitelyTyped/DefinitelyTyped
-
Functional Programming with TypeScript's Type System
While no actual Turing machine’s tape is infinitely long, I found issues in TypeScript with how finite generics are.
You have to define every possible count of generic arguments. And if you go above that count your type system degrades. I think there’s also a maximum of 10 or so before it doesn’t work. Thought that might have just been VSCode.
For example, Lodash enumerating types for # generic items per function: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/0452...
Admittedly I don’t understand the problem space well. I’ve just seen it happen to me and in others’ code. It might not actually be an issue, or is already fixed.
What are some alternatives?
pyre-check - Performant type-checking for python.
vite-tsconfig-paths - Support for TypeScript's path mapping in Vite
tsyringe - Lightweight dependency injection container for JavaScript/TypeScript
supabase-js - An isomorphic Javascript client for Supabase. Query your Supabase database, subscribe to realtime events, upload and download files, browse typescript examples, invoke postgres functions via rpc, invoke supabase edge functions, query pgvector.
typegoose - Typegoose - Define Mongoose models using TypeScript classes.
TypeScript - TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
bpmn-visualization-js - A TypeScript library for visualizing process execution data on BPMN diagrams
middy - 🛵 The stylish Node.js middleware engine for AWS Lambda 🛵
mypy - Optional static typing for Python
pokemon-showdown - Pokémon battle simulator.
twin.macro - 🦹♂️ Twin blends the magic of Tailwind with the flexibility of css-in-js (emotion, styled-components, solid-styled-components, stitches and goober) at build time.
swc - Rust-based platform for the Web