Passed
Pull Request — main (#384)
by
unknown
01:55
created

pincer.utils.shards   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 3
dl 0
loc 15
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A calculate_shard_id() 0 11 1
1
# Copyright Pincer 2021-Present
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
# Full MIT License can be found in `LICENSE` at the project root.
3
4
def calculate_shard_id(guild_id: Union[Snowflake, int], num_shards: int) -> int:
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'Snowflake'
Loading history...
Comprehensibility Best Practice introduced by
Undefined variable 'Union'
Loading history...
5
    """Calculates the shard receiving the events for a specified guild
6
7
    Parameters
8
    ----------
9
    guild_id : Optional[~pincer.utils.snowflake.Snowflake]
10
        The guild_id of the shard to look for
11
    num_shards : Optional[int]
12
        The number of shards.
13
    """
14
    return (guild_id >> 22) % num_shards
15