Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/extractor/semmle/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#Semantic version of extractor.
#Update this if any changes are made
VERSION = "7.1.7"
VERSION = "7.1.8"

PY_EXTENSIONS = ".py", ".pyw"

Expand Down
2 changes: 2 additions & 0 deletions python/extractor/tests/parser/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,5 @@
if 39:
r'a\
'
if 40:
f"{x:=^20}"
22 changes: 21 additions & 1 deletion python/extractor/tests/parser/template_strings_new.expected
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Module: [1, 0] - [18, 0]
Module: [1, 0] - [20, 0]
body: [
Assign: [1, 0] - [1, 14]
targets: [
Expand Down Expand Up @@ -191,4 +191,24 @@ Module: [1, 0] - [18, 0]
]
]
orelse: None
If: [18, 0] - [18, 5]
test:
Num: [18, 3] - [18, 4]
n: 7
text: '7'
body: [
Expr: [19, 4] - [19, 43]
value:
TemplateString: [19, 4] - [19, 43]
prefix: 't"'
values: [
TemplateStringPart: [19, 6] - [19, 31]
text: '"With a format specifier: "'
s: 'With a format specifier: '
Name: [19, 32] - [19, 36]
variable: Variable('name', None)
ctx: Load
]
]
orelse: None
]
2 changes: 2 additions & 0 deletions python/extractor/tests/parser/template_strings_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
t"Multiple {first} and {second} placeholders."
if 6:
t"Implicit concatenation: " t"Hello, {name}!" t" How are you?"
if 7:
t"With a format specifier: {name:=^20}"
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Syntax Error (in Python 3).

See below for a potential fix:

    ""
if 2:
    f"Hello, {name}!"
if 3:
    f"Value: {value:.2f}, Hex: {value:#x}"
if 4:
    "Just a regular string."
if 5:
    f"Multiple {first} and {second} placeholders."
if 6:
    "Implicit concatenation: " f"Hello, {name}!" " How are you?"
if 7:
    f"With a format specifier: {name:=^20}"

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty funny -- the alert is based on the current analysis, which indeed has a syntax error here (because of the parser issue that this PR fixes).

2 changes: 1 addition & 1 deletion python/extractor/tsg-python/tsp/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ module.exports = grammar({
_not_escape_sequence: $ => token.immediate('\\'),

format_specifier: $ => seq(
':',
token(prec(1,':')),
repeat(choice(
token(prec(1, /[^{}\n]+/)),
alias($.interpolation, $.format_expression)
Expand Down
18 changes: 13 additions & 5 deletions python/extractor/tsg-python/tsp/src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion python/extractor/tsg-python/tsp/src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading