-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework how a typed parameter is handled (#311)
This change utilizes the visitor pattern to process nodes of type typed_parameter and typed_default_parameter instead of manually checking children of the function def. This works because typed parameters are only within function defs. This commit also adds test cases to ensure this is working. This change also protects against the traceback found when encountering an unexpected *arg as a function parameter. Fixes #310 Signed-off-by: Eric Brown <[email protected]>
- Loading branch information
Showing
4 changed files
with
55 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
tests/unit/rules/python/stdlib/examples/ssl_context_set_ecdh_curve_typed_default_param.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# level: WARNING | ||
# start_line: 10 | ||
# end_line: 10 | ||
# start_column: 27 | ||
# end_column: 39 | ||
import ssl | ||
|
||
|
||
def set_curve(context: ssl.SSLContext = None) -> None: | ||
context.set_ecdh_curve("prime192v1") | ||
|
||
|
||
context = ssl.SSLContext() | ||
set_curve(context) |
14 changes: 14 additions & 0 deletions
14
tests/unit/rules/python/stdlib/examples/ssl_context_set_ecdh_curve_typed_param.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# level: WARNING | ||
# start_line: 10 | ||
# end_line: 10 | ||
# start_column: 27 | ||
# end_column: 39 | ||
import ssl | ||
|
||
|
||
def set_curve(context: ssl.SSLContext) -> None: | ||
context.set_ecdh_curve("prime192v1") | ||
|
||
|
||
context = ssl.SSLContext() | ||
set_curve(context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters