Americans rarely unite against something that's partially and/or possibly our fault.
918 karma · joined July 23, 2018
Americans rarely unite against something that's partially and/or possibly our fault.
$ python -m venv .venv
$ source .venv/bin/activate
$ pip install -r requirements.txt
Most IDEs will automatically pick up the .venv folderSince those version ranges of X don’t overlap, it isn’t possible to satisfy both A and B’s requirements. Node can handle this
https://www.typescriptlang.org/play?#code/AQMwrgdgxgLglgewqB...
This conflation of "optional" and "undefined-able" is more obvious in interfaces. This is why TypeScript added the `exactOptionalPropertyTypes` option:
https://www.typescriptlang.org/tsconfig#exactOptionalPropert...
Sometimes "is not defined" needs to be treated differently than "is set to undefined"
import typing
class Foo(typing.TypedDict):
a: int
def do_thing(value: Foo) -> None:
return
foo: Foo = {"a": 1}
do_thing(foo)
My complaint here is that Mypy doesn't go far enough with structural inference. I assume this is because it doesn't support anonymous TypedDicts, whereas TypeScript supports anonymous interfaces/types def create_user(user):
other_function(user)
Then how do I know what `user` is? Is it a dictionary? An object? If it's an object, where's its class definition? To find the answer I need to search for all the code that calls `create_user`, and then code that calls that code, and then code that calls that code, ad nauseam.Onboarding into a huge, untyped codebase is brutal
import typing
class Foo(typing.TypedDict):
a: int
def do_thing(value: Foo) -> None:
return
foo = {"a": 1}
# error: Argument 1 to "do_thing" has incompatible type "Dict[str, int]"; expected "Foo"
do_thing(foo)
But TypeScript can figure it out: interface Foo {
a: number
}
function doThing(value: Foo): void {
return
}
const foo = { a: 1 }
doThing(foo)The following code is valid:
function foo1(value?: number) {}
foo1()
But the following code will raise a type error: function foo2(value: number | undefined) {}
foo2()
In practice, that rarely becomes problematic. But it's good to know the differenceThis sounds bad off-hand but you have to consider the scale of China. Spain's population is roughly 3% of China. 3% of the US population is 10 million, which is less than the 16 million vacant homes in the US (https://www.nytimes.com/2022/03/10/realestate/vacancy-rate-b...). And that's still a generous comparison since more than 1 person lives in a home.
AFAIK (IANAL), companies have few restrictions on stock dilution as long as the dilution is in the best interest of the shareholders. You can make a legally defensible argument that one actor is bad and should be diluted, but it's probably hard to make a legally defensible argument for selectively diluting shares of idle shareholders.
Not saying the tradeoff isn't worth it, but pinning to dependency lockfiles isn't without downsides.
For example, let's say our platform supports multiple authentication methods. If we need to add a new auth method, how do we know all the spots we need to update? TypeScript can handle this using a sum type:
type AuthMethods = "push" | "sms" | "fancy_new_thing"
// No errors
const authMethodHandlers: {[key in AuthMethods]: CallableFunction} = {
push: () => {},
sms: () => {},
fancy_new_thing: () => {},
}
// Error: Property 'fancy_new_thing' is missing
const authMethodTitles: {[key in AuthMethods]: string} = {
push: "Push",
sms: "SMS",
}
With the above approach, static analysis tells us when we missed a spot. That adds a ton of safety and expedites feature work (since engineers don't need to manually find all the spots that need updating).