From 1813c7bba6959461112f38a788dc3a61e8cad9b3 Mon Sep 17 00:00:00 2001 From: Piotr Idzik <65706193+vil02@users.noreply.github.com> Date: Mon, 24 Mar 2025 18:49:09 +0100 Subject: [PATCH] feat: use `black` compliant formatting (#8393) --- src/data/guides/java-vs-python.md | 1 + .../content/factorial@m0umGQNdvg95UiNpQZsQN.md | 2 +- .../cpp/content/conan@ky_UqizToTZHC_b77qFi2.md | 1 + .../103-real-world/103-coding-assistance.md | 14 +++++--------- ...ions-builtin-functions@-DJgS6l2qngfwurExlmmT.md | 3 ++- .../content/write-through@RNITLR1FUQWkRbSBXTD_z.md | 6 +++--- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/data/guides/java-vs-python.md b/src/data/guides/java-vs-python.md index 9c8fe9bf3..e097e06c9 100644 --- a/src/data/guides/java-vs-python.md +++ b/src/data/guides/java-vs-python.md @@ -198,6 +198,7 @@ def divide(a, b): finally: print("Execution completed.") + print(divide(10, 2)) # Result: 5.0 print(divide(10, 0)) # Error: Division by zero is not allowed. ``` diff --git a/src/data/roadmaps/computer-science/content/factorial@m0umGQNdvg95UiNpQZsQN.md b/src/data/roadmaps/computer-science/content/factorial@m0umGQNdvg95UiNpQZsQN.md index 6fd689d37..afd691f80 100644 --- a/src/data/roadmaps/computer-science/content/factorial@m0umGQNdvg95UiNpQZsQN.md +++ b/src/data/roadmaps/computer-science/content/factorial@m0umGQNdvg95UiNpQZsQN.md @@ -16,7 +16,7 @@ def generate_permutations(s): # Current character current_char = s[i] # Remaining characters - remaining_chars = s[:i] + s[i+1:] + remaining_chars = s[:i] + s[i + 1 :] # Generate all permutations of the remaining characters for perm in generate_permutations(remaining_chars): # Add the current character to the front of each generated permutation diff --git a/src/data/roadmaps/cpp/content/conan@ky_UqizToTZHC_b77qFi2.md b/src/data/roadmaps/cpp/content/conan@ky_UqizToTZHC_b77qFi2.md index 19d9d82c9..f6d3392ce 100644 --- a/src/data/roadmaps/cpp/content/conan@ky_UqizToTZHC_b77qFi2.md +++ b/src/data/roadmaps/cpp/content/conan@ky_UqizToTZHC_b77qFi2.md @@ -45,6 +45,7 @@ Here's an example: ```python from conans import ConanFile, CMake + class MyLibraryConan(ConanFile): name = "MyLibrary" version = "0.1" diff --git a/src/data/roadmaps/prompt-engineering/content/103-real-world/103-coding-assistance.md b/src/data/roadmaps/prompt-engineering/content/103-real-world/103-coding-assistance.md index 24a82c910..d9f789930 100644 --- a/src/data/roadmaps/prompt-engineering/content/103-real-world/103-coding-assistance.md +++ b/src/data/roadmaps/prompt-engineering/content/103-real-world/103-coding-assistance.md @@ -15,9 +15,9 @@ The output will be something like: ```python import random -prepositions = ['at', 'in', 'on', 'with', 'under', 'over'] -verbs = ['run', 'jump', 'dance', 'sing', 'laugh', 'cry'] -nouns = ['cat', 'dog', 'tree', 'flower', 'book', 'computer'] +prepositions = ["at", "in", "on", "with", "under", "over"] +verbs = ["run", "jump", "dance", "sing", "laugh", "cry"] +nouns = ["cat", "dog", "tree", "flower", "book", "computer"] preposition = random.choice(prepositions) verb = random.choice(verbs) @@ -26,7 +26,6 @@ noun = random.choice(nouns) madlib = f"I {verb} {preposition} the {noun}." print(madlib) - ``` ## Commenting and Reformatting Code @@ -60,10 +59,9 @@ num_points = 50 for i in range(num_points): # Calculate the y value of the wave using the sine function from the math module y = int(round(amplitude * math.sin(2 * math.pi * frequency * i / num_points))) - - # Print a space for padding, followed by an asterisk at the appropriate position on the wave - print(' ' * (amplitude + y) + '*') + # Print a space for padding, followed by an asterisk at the appropriate position on the wave + print(" " * (amplitude + y) + "*") ``` ## Debugging @@ -113,7 +111,6 @@ for i in numbers: if j in numbers: numbers.remove(j) print(numbers) - ``` Note that we asked the bot to "act like a senior developer" to optimize the script. You can also dictate that it have a certain area of expertise (e.g., sorting algorithms) or number of years of experience. Alternatively, if you have a script that seems overly complicated, you can ask ChatGPT to write that script "as a very junior developer." @@ -151,7 +148,6 @@ salary = float(input("Enter employee's salary: ")) ss_tax = salary * 0.062 print("Social Security tax is: $", round(ss_tax, 2)) - ``` Learn more from the following resources: diff --git a/src/data/roadmaps/python/content/functions-builtin-functions@-DJgS6l2qngfwurExlmmT.md b/src/data/roadmaps/python/content/functions-builtin-functions@-DJgS6l2qngfwurExlmmT.md index bea7892b6..6f5fe11c1 100644 --- a/src/data/roadmaps/python/content/functions-builtin-functions@-DJgS6l2qngfwurExlmmT.md +++ b/src/data/roadmaps/python/content/functions-builtin-functions@-DJgS6l2qngfwurExlmmT.md @@ -8,7 +8,8 @@ In programming, a function is a reusable block of code that executes a certain f def greet(name): print(f"Hello, {name}!") -greet("Roadmap.sh") + +greet("Roadmap.sh") ``` Visit the following resources to learn more: diff --git a/src/data/roadmaps/system-design/content/write-through@RNITLR1FUQWkRbSBXTD_z.md b/src/data/roadmaps/system-design/content/write-through@RNITLR1FUQWkRbSBXTD_z.md index 5559860a3..434349b81 100644 --- a/src/data/roadmaps/system-design/content/write-through@RNITLR1FUQWkRbSBXTD_z.md +++ b/src/data/roadmaps/system-design/content/write-through@RNITLR1FUQWkRbSBXTD_z.md @@ -9,15 +9,15 @@ The application uses the cache as the main data store, reading and writing data Application code: ```python -set_user(12345, {"foo":"bar"}) +set_user(12345, {"foo": "bar"}) ``` Cache code: ```python def set_user(user_id, values): - user = db.query("UPDATE Users WHERE id = {0}", user_id, values) - cache.set(user_id, user) + user = db.query("UPDATE Users WHERE id = {0}", user_id, values) + cache.set(user_id, user) ``` Write-through is a slow overall operation due to the write operation, but subsequent reads of just written data are fast. Users are generally more tolerant of latency when updating data than reading data. Data in the cache is not stale.