Skip to content

Commit 19bff00

Browse files
cclaussgithub-actionspre-commit-ci[bot]
authored
Adopt Python >= 3.8 assignment expressions using auto-walrus (#7737)
* Adopt Python >= 3.8 assignment expressions using auto-walrus * updating DIRECTORY.md * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 15c93e5 commit 19bff00

File tree

7 files changed

+642
-639
lines changed

7 files changed

+642
-639
lines changed

.pre-commit-config.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ repos:
1313
)$
1414
- id: requirements-txt-fixer
1515

16+
- repo: https://github.com/MarcoGorelli/auto-walrus
17+
rev: v0.2.1
18+
hooks:
19+
- id: auto-walrus
20+
1621
- repo: https://github.com/psf/black
1722
rev: 22.10.0
1823
hooks:

DIRECTORY.md

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
* [Count 1S Brian Kernighan Method](bit_manipulation/count_1s_brian_kernighan_method.py)
4646
* [Count Number Of One Bits](bit_manipulation/count_number_of_one_bits.py)
4747
* [Gray Code Sequence](bit_manipulation/gray_code_sequence.py)
48+
* [Highest Set Bit](bit_manipulation/highest_set_bit.py)
4849
* [Is Even](bit_manipulation/is_even.py)
4950
* [Reverse Bits](bit_manipulation/reverse_bits.py)
5051
* [Single Bit Manipulation Operations](bit_manipulation/single_bit_manipulation_operations.py)
@@ -326,6 +327,7 @@
326327
## Financial
327328
* [Equated Monthly Installments](financial/equated_monthly_installments.py)
328329
* [Interest](financial/interest.py)
330+
* [Price Plus Tax](financial/price_plus_tax.py)
329331

330332
## Fractals
331333
* [Julia Sets](fractals/julia_sets.py)
@@ -669,6 +671,7 @@
669671
* [Horizontal Projectile Motion](physics/horizontal_projectile_motion.py)
670672
* [Kinetic Energy](physics/kinetic_energy.py)
671673
* [Lorentz Transformation Four Vector](physics/lorentz_transformation_four_vector.py)
674+
* [Malus Law](physics/malus_law.py)
672675
* [N Body Simulation](physics/n_body_simulation.py)
673676
* [Newtons Law Of Gravitation](physics/newtons_law_of_gravitation.py)
674677
* [Newtons Second Law Of Motion](physics/newtons_second_law_of_motion.py)

ciphers/enigma_machine2.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ def _validator(
8686
"""
8787
# Checks if there are 3 unique rotors
8888

89-
unique_rotsel = len(set(rotsel))
90-
if unique_rotsel < 3:
89+
if (unique_rotsel := len(set(rotsel))) < 3:
9190
raise Exception(f"Please use 3 unique rotors (not {unique_rotsel})")
9291

9392
# Checks if rotor positions are valid

data_structures/linked_list/doubly_linked_list_two.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,8 @@ def get_node(self, item: int) -> Node:
143143
raise Exception("Node not found")
144144

145145
def delete_value(self, value):
146-
node = self.get_node(value)
147146

148-
if node is not None:
147+
if (node := self.get_node(value)) is not None:
149148
if node == self.head:
150149
self.head = self.head.get_next()
151150

dynamic_programming/fibonacci.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ def get(self, index: int) -> list:
1818
>>> Fibonacci().get(5)
1919
[0, 1, 1, 2, 3]
2020
"""
21-
difference = index - (len(self.sequence) - 2)
22-
if difference >= 1:
21+
if (difference := index - (len(self.sequence) - 2)) >= 1:
2322
for _ in range(difference):
2423
self.sequence.append(self.sequence[-1] + self.sequence[-2])
2524
return self.sequence[:index]

0 commit comments

Comments
 (0)