Skip to content

Adopt Python >= 3.8 assignment expressions using auto-walrus #7737

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 3 commits into from
Oct 28, 2022
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
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ repos:
)$
- id: requirements-txt-fixer

- repo: https://github.com/MarcoGorelli/auto-walrus
rev: v0.2.1
hooks:
- id: auto-walrus

- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
Expand Down
3 changes: 3 additions & 0 deletions DIRECTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
* [Count 1S Brian Kernighan Method](bit_manipulation/count_1s_brian_kernighan_method.py)
* [Count Number Of One Bits](bit_manipulation/count_number_of_one_bits.py)
* [Gray Code Sequence](bit_manipulation/gray_code_sequence.py)
* [Highest Set Bit](bit_manipulation/highest_set_bit.py)
* [Is Even](bit_manipulation/is_even.py)
* [Reverse Bits](bit_manipulation/reverse_bits.py)
* [Single Bit Manipulation Operations](bit_manipulation/single_bit_manipulation_operations.py)
Expand Down Expand Up @@ -326,6 +327,7 @@
## Financial
* [Equated Monthly Installments](financial/equated_monthly_installments.py)
* [Interest](financial/interest.py)
* [Price Plus Tax](financial/price_plus_tax.py)

## Fractals
* [Julia Sets](fractals/julia_sets.py)
Expand Down Expand Up @@ -669,6 +671,7 @@
* [Horizontal Projectile Motion](physics/horizontal_projectile_motion.py)
* [Kinetic Energy](physics/kinetic_energy.py)
* [Lorentz Transformation Four Vector](physics/lorentz_transformation_four_vector.py)
* [Malus Law](physics/malus_law.py)
* [N Body Simulation](physics/n_body_simulation.py)
* [Newtons Law Of Gravitation](physics/newtons_law_of_gravitation.py)
* [Newtons Second Law Of Motion](physics/newtons_second_law_of_motion.py)
Expand Down
3 changes: 1 addition & 2 deletions ciphers/enigma_machine2.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ def _validator(
"""
# Checks if there are 3 unique rotors

unique_rotsel = len(set(rotsel))
if unique_rotsel < 3:
if (unique_rotsel := len(set(rotsel))) < 3:
raise Exception(f"Please use 3 unique rotors (not {unique_rotsel})")

# Checks if rotor positions are valid
Expand Down
3 changes: 1 addition & 2 deletions data_structures/linked_list/doubly_linked_list_two.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,8 @@ def get_node(self, item: int) -> Node:
raise Exception("Node not found")

def delete_value(self, value):
node = self.get_node(value)

if node is not None:
if (node := self.get_node(value)) is not None:
if node == self.head:
self.head = self.head.get_next()

Expand Down
3 changes: 1 addition & 2 deletions dynamic_programming/fibonacci.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ def get(self, index: int) -> list:
>>> Fibonacci().get(5)
[0, 1, 1, 2, 3]
"""
difference = index - (len(self.sequence) - 2)
if difference >= 1:
if (difference := index - (len(self.sequence) - 2)) >= 1:
for _ in range(difference):
self.sequence.append(self.sequence[-1] + self.sequence[-2])
return self.sequence[:index]
Expand Down
Loading