Skip to content

Commit 6ff74f2

Browse files
committed
📝 Tweak docs
1 parent ecca5f0 commit 6ff74f2

5 files changed

Lines changed: 33 additions & 20 deletions

File tree

docs/en/docs/advanced/settings.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ For this reason it's common to provide them in environment variables that are re
88

99
/// tip
1010

11-
To understand environment variables you can read the page [Environment Variables](../environment-variables.md){.internal-link target=_blank}
11+
To understand environment variables you can read [Environment Variables](../environment-variables.md){.internal-link target=_blank}.
1212

1313
///
1414

1515
## Types and validation
1616

1717
These environment variables can only handle text strings, as they are external to Python and have to be compatible with other programs and the rest of the system (and even with different operating systems, as Linux, Windows, macOS).
1818

19-
That means that any value read in Python from an environment variable will be a `str`, and any conversion to a different type or validation has to be done in code.
19+
That means that any value read in Python from an environment variable will be a `str`, and any conversion to a different type or any validation has to be done in code.
2020

2121
## Pydantic `Settings`
2222

docs/en/docs/environment-variables.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ You can read more about it at <a href="https://12factor.net/config" class="exter
161161

162162
These environment variables can only handle **text strings**, as they are external to Python and have to be compatible with other programs and the rest of the system (and even with different operating systems, as Linux, Windows, macOS).
163163

164-
That means that **any value** read in Python from an environment variable **will be a `str`**, and any conversion to a different type or validation has to be done in code.
164+
That means that **any value** read in Python from an environment variable **will be a `str`**, and any conversion to a different type or any validation has to be done in code.
165165

166166
You will learn more about using environment variables for handling **application settings** in the [Advanced User Guide - Settings and Environment Variables](./advanced/settings.md){.internal-link target=_blank}.
167167

168-
## `PATH` environment variable
168+
## `PATH` Environment Variable
169169

170170
There is a **special** environment variable called **`PATH`** that is used by the operating systems (Linux, macOS, Windows) to find programs to run.
171171

@@ -192,13 +192,13 @@ This means that the system should look for programs in the directories:
192192
//// tab | Windows
193193

194194
```plaintext
195-
C:\Program Files\Python39\Scripts;C:\Program Files\Python39;C:\Windows\System32
195+
C:\Program Files\Python312\Scripts;C:\Program Files\Python312;C:\Windows\System32
196196
```
197197

198198
This means that the system should look for programs in the directories:
199199

200-
* `C:\Program Files\Python39\Scripts`
201-
* `C:\Program Files\Python39`
200+
* `C:\Program Files\Python312\Scripts`
201+
* `C:\Program Files\Python312`
202202
* `C:\Windows\System32`
203203

204204
////
@@ -236,7 +236,7 @@ Let's say you install Python and it ends up in a directory `C:\opt\custompython\
236236
If you say yes to update the `PATH` environment variable, then the installer will add `C:\opt\custompython\bin` to the `PATH` environment variable.
237237

238238
```plaintext
239-
C:\Program Files\Python39\Scripts;C:\Program Files\Python39;C:\Windows\System32;C:\opt\custompython\bin
239+
C:\Program Files\Python312\Scripts;C:\Program Files\Python312;C:\Windows\System32;C:\opt\custompython\bin
240240
```
241241

242242
This way, when you type `python` in the terminal, the system will find the Python program in `C:\opt\custompython\bin` (the last directory) and use that one.

docs/en/docs/tutorial/security/first-steps.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ The <a href="https://github.com/Kludex/python-multipart" class="external-link" t
5858

5959
However, if you use the `pip install fastapi` command, the `python-multipart` package is not included by default.
6060

61-
To install it manually, make sure you create a [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and then install it with:
61+
To install it manually, make sure you create a [virtual environment](../../virtual-environments.md){.internal-link target=_blank}, activate it, and then install it with:
6262

63-
`pip install python-multipart`
63+
```console
64+
$ pip install python-multipart
65+
```
6466

6567
This is because **OAuth2** uses "form data" for sending the `username` and `password`.
6668

docs/en/docs/tutorial/security/oauth2-jwt.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ If you want to play with JWT tokens and see how they work, check <a href="https:
3030

3131
We need to install `PyJWT` to generate and verify the JWT tokens in Python.
3232

33-
Make sure you create a [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and then install `pyjwt`:
33+
Make sure you create a [virtual environment](../../virtual-environments.md){.internal-link target=_blank}, activate it, and then install `pyjwt`:
3434

3535
<div class="termy">
3636

docs/en/docs/virtual-environments.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ But you could customize it passing an additional argument with the directory nam
106106

107107
////
108108

109-
That creates a new virtual environment in a directory called `.venv`.
109+
That command creates a new virtual environment in a directory called `.venv`.
110110

111111
/// details | `.venv` or other name
112112

@@ -269,7 +269,7 @@ $ echo "*" > .venv/.gitignore
269269
/// details | What that command means
270270

271271
* `echo "*"`: will "print" the text `*` in the terminal (the next part changes that a bit)
272-
* `>`: anything printed to the terminal by the previous command before `>` should not be printed but instead written to the file that goes next to `>`
272+
* `>`: anything printed to the terminal by the command to the left of `>` should not be printed but instead written to the file that goes to the right of `>`
273273
* `.gitignore`: the name of the file where the text should be written
274274

275275
And `*` for Git means "everything". So, it will ignore everything in the `.venv` directory.
@@ -300,7 +300,7 @@ If you're in a hurry and don't want to use a file to declare your project's pack
300300

301301
/// tip
302302

303-
It's a (very) good idea to put the packages and versions your program needs in a file later (for example `requirements.txt` or `pyproject.toml`).
303+
It's a (very) good idea to put the packages and versions your program needs in a file (for example `requirements.txt` or `pyproject.toml`).
304304

305305
///
306306

@@ -358,6 +358,7 @@ If you have <a href="https://github.com/astral-sh/uv" class="external-link" targ
358358

359359
```console
360360
$ uv pip install -r requirements.txt
361+
---> 100%
361362
```
362363

363364
</div>
@@ -486,7 +487,7 @@ flowchart LR
486487
end
487488
```
488489

489-
But then if you want to run `priosner-of-azkaban`, you will need to uninstall `harry` version `1` and install `harry` version `3` (or just installing version `3` would automatically uninstall version `1`).
490+
But then if you want to run `prisoner-of-azkaban`, you will need to uninstall `harry` version `1` and install `harry` version `3` (or just installing version `3` would automatically uninstall version `1`).
490491

491492
<div class="termy">
492493

@@ -498,6 +499,8 @@ $ pip install "harry==3"
498499

499500
And then you would end up with `harry` version `3` installed in your global Python environment.
500501

502+
And if you try to run `philosophers-stone` again, there's a chance it would **not work** because it needs `harry` version `1`.
503+
501504
```mermaid
502505
flowchart LR
503506
subgraph global[global env]
@@ -513,7 +516,13 @@ flowchart LR
513516
end
514517
```
515518

516-
Now, imagine that with **many** other **packages** that all your **projects depend on**. That's very difficult to manage. And you would probably end up trying to run some projects with some **incompatible versions** of the packages, and not knowing why some are working or not.
519+
/// tip
520+
521+
It's very common in Python packages to try the best to **avoid breaking changes** in **new versions**, but it's better to be safe, and install newer versions intentionally and when you can run the tests to check everything is working correctly.
522+
523+
///
524+
525+
Now, imagine that with **many** other **packages** that all your **projects depend on**. That's very difficult to manage. And you would probably end up running some projects with some **incompatible versions** of the packages, and not knowing why something isn't working.
517526

518527
Also, depending on your operating system (e.g. Linux, Windows, macOS), it could have come with Python already installed. And in that case it probably had some packages pre-installed with some specific versions **needed by your system**. If you install packages in the global Python environment, you could end up **breaking** some of the programs that came with your operating system.
519528

@@ -610,7 +619,7 @@ $ source .venv/Scripts/activate
610619

611620
////
612621

613-
That command will create some [environment variables](environment-variables.md){.internal-link target=_blank} that will be available for the next commands.
622+
That command will create or modify some [environment variables](environment-variables.md){.internal-link target=_blank} that will be available for the next commands.
614623

615624
One of those variables is the `PATH` variable.
616625

@@ -620,7 +629,7 @@ You can learn more about the `PATH` environment variable in the [Environment Var
620629

621630
///
622631

623-
Activating a virtual environment adds its path, `.venv/bin` (on Linux and macOS) or `.venv\Scripts` (on Windows) to the `PATH` environment variable.
632+
Activating a virtual environment adds its path `.venv/bin` (on Linux and macOS) or `.venv\Scripts` (on Windows) to the `PATH` environment variable.
624633

625634
Let's say that before activating the environment, the `PATH` variable looked like this:
626635

@@ -701,7 +710,9 @@ and use that one.
701710

702711
////
703712

704-
Activating a virtual environment also changes a couple of other things, but this is one of the most important details.
713+
An important detail is that it will put the virtual environment path at the **beginning** of the `PATH` variable. The system will find it **before** finding any other Python available. This way, when you run `python`, it will use the Python **from the virtual environment** instead of any other `python` (for example, a `python` from a global environment).
714+
715+
Activating a virtual environment also changes a couple of other things, but this is one of the most important things it does.
705716

706717
## Checking a Virtual Environment
707718

@@ -823,7 +834,7 @@ Once you are ready and want to use a tool to **manage the entire project**, pack
823834
* Manage the **virtual environment** for your projects
824835
* Install **packages**
825836
* Manage package **dependencies and versions** for your project
826-
* Make sure you have an **exact** set of packages and versions to install, including their dependencies, so that you can be sure that you can run your project exactly the same as in your computer while developing, this is called **locking**
837+
* Make sure you have an **exact** set of packages and versions to install, including their dependencies, so that you can be sure that you can run your project in production exactly the same as in your computer while developing, this is called **locking**
827838
* And many other things
828839

829840
## Conclusion

0 commit comments

Comments
 (0)