You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Code formatting refers to the consistent styling of your code - how it looks visually.
5
+
**Code formatting** refers to the consistent styling of your code - how it looks visually.
6
6
This includes indentation, spacing, line length, quote styles, and other stylistic choices that don't affect how the code runs but impact how it reads.
7
7
8
-
A code formatter automatically reformats your code to follow a consistent style.
9
-
Popular Python formatters include:
10
-
11
-
-**black**: An opinionated formatter that enforces a strict style with minimal configuration.
12
-
-**ruff**: A fast formatter that can also perform linting (checking for code quality issues).
8
+
**Linting** checks your code for potential bugs, code smells, and programming errors.
9
+
It catches issues like unused variables, undefined names, or overly complex code before they cause problems.
13
10
14
11
## Why
15
12
16
-
Consistent formatting serves several important purposes:
13
+
**Formatting** helps you focus on logic rather than style:
17
14
18
-
**Focus on logic, not style**: With automatic formatting, you don't waste time or mental energy deciding where to put spaces, how to break lines, or arguing about style preferences during code reviews.
15
+
-**Save time and energy**: No more deciding where to put spaces or how to break lines
16
+
-**Improved readability**: Consistent code is easier to read and understand
17
+
-**Better collaboration**: Everyone's code looks the same, so git diffs show real changes instead of whitespace adjustments
19
18
20
-
**Improved readability**: Consistent code is easier to read and understand.
21
-
When all code follows the same patterns, you can focus on what the code does rather than getting distracted by inconsistent styling.
19
+
**Linting** catches bugs before they happen:
22
20
23
-
**Better collaboration**: When everyone's code looks the same, it's easier to work together.
24
-
Code reviews focus on functionality rather than style preferences, and git diffs show real changes instead of whitespace adjustments.
21
+
-**Early bug detection**: Find issues like unused variables or undefined names before running your code
Copy file name to clipboardExpand all lines: docs/index.md
+1-5Lines changed: 1 addition & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ Topics that will be covered:
14
14
-[Packages](packages.md)
15
15
-[Writing documentation](documentation.md)
16
16
-[Testing with `pytest`](tests.md)
17
-
- Formatting/linting your code with Ruff
17
+
-[Formatting/linting your code with Ruff](formatting.md)
18
18
- Continuous Integration (CI)
19
19
- Publishing your code on the PyPI (CD)
20
20
@@ -27,7 +27,3 @@ You won't need any advanced Python concepts, but understanding basic syntax will
27
27
**Don't worry in case you don't understand everything right away!**
28
28
All of this is very intimidating at first, I know, I've been there.
29
29
It took me a long time to learn how to use these tools, and I'm still learning more every day.
30
-
31
-
!!! note
32
-
33
-
The material presented here is mostly based on my experience, but has also been inspired by [this excellent guide](https://learn.scientific-python.org/development/) from the [Scientific Python project](https://github.com/scientific-python).
0 commit comments