but my fonction to fill it is a tuple of (int, list[booleen])

horw to force the right detection

with Pool(nb_process) as pool: # multicore first segment
arrays = dict(pool.starmap(sieve_residue_class_multicore, [(init.limit, init.prod_exclude, init.master_loop, init.candidates, init.add[i], init.candidates[i]) for i in range(init.nb_candidate)]))
arrays[1][0] = False # as exemple i have warning here he need a str as key

def sieve_residue_class_multicore(n, prod_exclude, master_loop, candidates, add, key):
"""
Perform sieve calculations for a specific residue class set.
Args:
n (int): The limit for sieve calculations.
prod_exclude (int): The modulo value for the residue class set.
master_loop (list[list[int]]): Reduced list of prime indices for the residue class set.
candidates (list[int]): List of values in the residue class set.
add list[int]: Values used for square calculations.
key (int): The key for the dictionary where the results will be stored.
Returns:
tuple[int, bitarray]: A tuple containing the key (residue class set value) and binary list
"""
value = bitarray()
value.extend(bitarray('1') * (n // prod_exclude + 1))
for nth in range(len(master_loop)): # Iterate each prod_exclude range
nthx = nth * prod_exclude
for ix in master_loop[nth]: # Iterate the sublist to know if prime, datas are the index in candidates.
step = nthx + candidates[ix] # Convert data into real number
value[(step ** 2 + (step * add[ix] << 1)) // prod_exclude::step] = 0b0
return key, value

def sieve_antoine_splitter(init, nb_process, num_partitions):
with Pool(nb_process) as pool: # multicore first segment
arrays = dict(pool.starmap(sieve_residue_class_multicore, [(init.limit, init.prod_exclude, init.master_loop, init.candidates, init.add[i], init.candidates[i]) for i in range(init.nb_candidate)]))
arrays[1][0] = False ### STILL don't understanding the KEYS are INTEGER
nb_partition = len(arrays[1]) // num_partitions
partitions = {} # dictionnary of dictionnairy
for i in range(num_partitions):
start = i * nb_partition
end = (i + 1) * nb_partition if i < num_partitions - 1 else None
partitions[i + 1] = {key: arrays[key][start:end] for key in arrays}
return partitions, nb_partition

Annotate the return type of sieve_residue_class_multicore. This is probably insufficient because it’s return type may be swallowed by starmap.

Annotate the type of the array variable. This usually helps most if the inferred type includes Unknown, but it’s still worth trying since it gives the type checker more information for deduction.

Forcibly override the type checker with typing.cast