File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Tips and Tricks
2
+
3
+ ## TYPE_CHECKING
4
+
5
+ Do you use ` TYPE_CHECKING ` in bricks? ` TYPE_CHECKING ` is a special constant that is ` True ` for static type checkers,
6
+ but ` False ` at runtime.
7
+
8
+ Example:
9
+ ``` python
10
+ if TYPE_CHECKING :
11
+ from mypy_boto3_s3.service_resource import Object as S3Object
12
+ ```
13
+
14
+ The ` poly check ` command will identify the import and expect it to be defined as a dependency.
15
+ Usually, these dev-specific dependencies are added as dev-dependencies (and that is correct).
16
+
17
+ This means that the ` poly check ` command will report it as a missing dependency.
18
+
19
+
20
+ ### Solution
21
+ To resolve this, you can add _ optional dependencies_ in the projects that use the brick with the TYPE_CHECKING constant.
22
+
23
+ Example, using the dev-only "boto3-stubs" library:
24
+ ``` python
25
+ # add the dev-dependencies for every project that is using the brick
26
+ [project.optional- dependencies]
27
+ local- dev = [" boto3-stubs[s3]" ]
28
+ ```
Original file line number Diff line number Diff line change 18
18
- " Examples & Production Systems " : examples.md
19
19
- " Videos & tutorials " : videos.md
20
20
- " Configuring your Python IDE " : ide.md
21
+ - " Tips & Tricks " : tips.md
21
22
- " About this Open Source Project " : about.md
22
23
23
24
theme :
You can’t perform that action at this time.
0 commit comments