Skip to content

[mypy] Add/fix type annotations for bit manipulation algorithms #4056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bit_manipulation/binary_and_operator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# https://www.tutorialspoint.com/python3/bitwise_operators_example.htm


def binary_and(a: int, b: int):
def binary_and(a: int, b: int) -> str:
"""
Take in 2 integers, convert them to binary,
return a binary number that is the
Expand Down
2 changes: 1 addition & 1 deletion bit_manipulation/binary_or_operator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# https://www.tutorialspoint.com/python3/bitwise_operators_example.htm


def binary_or(a: int, b: int):
def binary_or(a: int, b: int) -> str:
"""
Take in 2 integers, convert them to binary, and return a binary number that is the
result of a binary or operation on the integers provided.
Expand Down
2 changes: 1 addition & 1 deletion bit_manipulation/binary_xor_operator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# https://www.tutorialspoint.com/python3/bitwise_operators_example.htm


def binary_xor(a: int, b: int):
def binary_xor(a: int, b: int) -> str:
"""
Take in 2 integers, convert them to binary,
return a binary number that is the
Expand Down
6 changes: 3 additions & 3 deletions bit_manipulation/single_bit_manipulation_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""Provide the functionality to manipulate a single bit."""


def set_bit(number: int, position: int):
def set_bit(number: int, position: int) -> int:
"""
Set the bit at position to 1.

Expand All @@ -21,7 +21,7 @@ def set_bit(number: int, position: int):
return number | (1 << position)


def clear_bit(number: int, position: int):
def clear_bit(number: int, position: int) -> int:
"""
Set the bit at position to 0.

Expand All @@ -37,7 +37,7 @@ def clear_bit(number: int, position: int):
return number & ~(1 << position)


def flip_bit(number: int, position: int):
def flip_bit(number: int, position: int) -> int:
"""
Flip the bit at position.

Expand Down