typing Questions
4
Solved
I have tried to google for answers to this, but perhaps there isn't widely available research or perhaps I'm not using the right terms.
Basically, I would like to have some idea as to the average ...
Emigrate asked 4/11, 2010 at 16:9
3
Solved
Hi I have following issue. I have prisma transaction but I would like to pass the prisma transaction client into a function like this:
...
prisma.$transaction(async (tx) => {
someFunction(t...
Rb asked 1/10, 2023 at 9:23
2
Solved
I'm trying to write a function in Typescript that maps an object, while guaranteeing that it keeps the same keys. I've tried various approaches to this, but haven't found a way that works:
function...
Follow asked 23/11, 2022 at 19:55
10
Solved
Is it possible to define an interface which has some information on the format of a string? Take the following example:
interface timeMarkers{
markerTime: string[]
};
an example would be:
{
...
Tundra asked 20/7, 2018 at 15:22
1
Solved
I'd like to type hint that a pandas dataframe must have a datetimeindex. I was hoping there might be some way to do this with protocols but looks like no. Something in the spirit of this:
class TSF...
12
Solved
Ada, Pascal and many other languages support ranges, a way to subtype integers.
A range is a signed integer value which ranges from a value (first) to another (last).
It's easy to implement a...
4
When we run our build, we found the following error
ERROR in node_modules/@types/ramda/index.d.ts:373:64 - error TS1110: Type expected.
373 (<S1 extends string, S2 extends string>(s1: S1, s2:...
6
Solved
Let's suppose there's a typing file for library X which includes some interfaces.
interface I1 {
x: any;
}
interface I2 {
y: {
a: I1,
b: I1,
c: I1
}
z: any
}
In order to work with this li...
Meingoldas asked 30/3, 2016 at 14:6
2
Solved
Does type narrowing with the in operator only work for literals or am I missing something?
Help me understand why this is happening please.
interface A {
a: string;
}
interface B {
b: number;
}
...
Splay asked 4/5, 2021 at 10:25
4
Solved
I am using the following type in my TypScript:
interface ExerciseData {
id : number;
name : string;
vocabulary : {
from : string;
to : string;
}[];
}
Now I'd like to create a variable that...
Bandoline asked 10/1, 2015 at 11:3
3
Solved
I would like to only allow specific components as children. For example, let's say I have a Menu component, that should only contain MenuItem as children, like this:
<Menu>
<MenuItem /&g...
Ceramist asked 23/8, 2019 at 14:3
6
Solved
this is an example input interface
export interface CssProperties {
alignContent: number | string | null;
alignItems: number | string | null;
alignSelf: number | string | null;
alignmentBaselin...
Penrod asked 10/2, 2021 at 16:1
2
Solved
Consider the following minimal working example:
#!/usr/bin/env python3
from PySide6.QtCore import QTimer
from PySide6.QtWidgets import QLabel, QApplication
app = QApplication()
label = QLabel('La...
5
Solved
I am trying to write a function which takes a parameter of type boolean and returns one of two types, depending on the value of the input. I have found two approaches:
function dependsOnParameter&...
Cypher asked 15/10, 2018 at 13:30
11
Solved
I wondered if there is a programming language which compiles to machine code/binary that features dynamic and/or weak typing (not bytecode then executed by a VM, that's something completely differe...
Pavis asked 31/3, 2010 at 17:24
3
Solved
I'm trying to introduce static type annotations to my codebase where applicable. One case is when reading a JSON, the resulting object will be a dictionary keyed by strings, with values of one of t...
Fikes asked 5/12, 2018 at 18:55
2
Solved
How can I get the literal value out of a Literal[] from typing?
from typing import Literal, Union
Add = Literal['add']
Multiply = Literal['mul']
Action = Union[Add,Multiply]
def do(a: Action):
...
Postbellum asked 3/12, 2019 at 18:50
1
Solved
Error message
While using a conda environment and pre-commit I receive the error:
error: Library stubs not installed for "requests" (or incompatible with Python 3.10)
The full erro...
Abelmosk asked 4/9, 2022 at 23:42
9
Solved
With iTerm2 1.0.0 on Mac OS X 10.6.8, I'd like to delete from cursor to the next end of word, i.e. deleting one word forward. I tried Alt+d but this types the delta operator symbol ∂ and doesn't de...
Thiosinamine asked 9/9, 2012 at 1:17
2
Solved
If I have a key in a dictionary with an invalid identifier, such as A(2). How can I create a TypedDict with this field?
E.g
from typing import TypedDict
class RandomAlphabet(TypedDict):
A(2):...
Gunny asked 31/1, 2020 at 11:56
4
Solved
I have seen typing.Callable, but I didn't find any useful docs about it. What exactly is typing.Callable?
1
I have the following class
@dataclass_json
@dataclass
class Input:
sources: List[Sources] =None
Transformations: List[str] =None
As well as:
@dataclass_json
@dataclass
class Source:
type: s...
Sacksen asked 1/5, 2020 at 11:6
0
How do I test for subtypes in both Python 2 and Python 3?
In Python 2.7.18:
>>> import typing
>>> type_ = typing.List[str]
>>> issubclass(type_, typing.List)
True
But in...
Portulaca asked 23/1, 2022 at 18:36
1
Solved
Please have a look at the following little demo:
Function f should accept ONE pair of the form ['stringX', 'stringXstringX'] (-> this is working)
But function g should accept A VARIABLE NUMBER ...
Bikol asked 21/11, 2021 at 20:48
1
Solved
tl;dr in Rust, is there a "strong" type alias (or typing mechanism) such that the rustc compiler will reject (emit an error) for mix-ups that may be the same underlying type?
Problem
Curr...
1 Next >
© 2022 - 2025 — McMap. All rights reserved.