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
212 changes: 54 additions & 158 deletions .basedpyright/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,38 @@
"lineCount": 1
}
},
{
"code": "reportUnknownVariableType",
"range": {
"startColumn": 8,
"endColumn": 11,
"lineCount": 1
}
},
{
"code": "reportUnknownMemberType",
"range": {
"startColumn": 14,
"endColumn": 37,
"lineCount": 1
}
},
{
"code": "reportAttributeAccessIssue",
"range": {
"startColumn": 23,
"endColumn": 37,
"lineCount": 1
}
},
{
"code": "reportUnknownVariableType",
"range": {
"startColumn": 15,
"endColumn": 18,
"lineCount": 1
}
},
{
"code": "reportArgumentType",
"range": {
Expand Down Expand Up @@ -1973,14 +2005,6 @@
"lineCount": 1
}
},
{
"code": "reportUnknownVariableType",
"range": {
"startColumn": 38,
"endColumn": 62,
"lineCount": 1
}
},
{
"code": "reportUnknownVariableType",
"range": {
Expand Down Expand Up @@ -2213,14 +2237,6 @@
"lineCount": 1
}
},
{
"code": "reportArgumentType",
"range": {
"startColumn": 12,
"endColumn": 16,
"lineCount": 1
}
},
{
"code": "reportUnknownMemberType",
"range": {
Expand Down Expand Up @@ -7870,24 +7886,24 @@
{
"code": "reportUnknownArgumentType",
"range": {
"startColumn": 29,
"endColumn": 32,
"startColumn": 39,
"endColumn": 42,
"lineCount": 1
}
},
{
"code": "reportUnknownArgumentType",
"range": {
"startColumn": 42,
"endColumn": 51,
"startColumn": 52,
"endColumn": 61,
"lineCount": 1
}
},
{
"code": "reportUnknownVariableType",
"range": {
"startColumn": 28,
"endColumn": 31,
"startColumn": 24,
"endColumn": 27,
"lineCount": 1
}
},
Expand Down Expand Up @@ -8358,24 +8374,24 @@
{
"code": "reportUnknownArgumentType",
"range": {
"startColumn": 29,
"endColumn": 32,
"startColumn": 39,
"endColumn": 42,
"lineCount": 1
}
},
{
"code": "reportUnknownArgumentType",
"range": {
"startColumn": 42,
"endColumn": 51,
"startColumn": 52,
"endColumn": 61,
"lineCount": 1
}
},
{
"code": "reportUnknownVariableType",
"range": {
"startColumn": 28,
"endColumn": 31,
"startColumn": 24,
"endColumn": 27,
"lineCount": 1
}
},
Expand Down Expand Up @@ -8662,24 +8678,24 @@
{
"code": "reportUnknownArgumentType",
"range": {
"startColumn": 29,
"endColumn": 32,
"startColumn": 39,
"endColumn": 42,
"lineCount": 1
}
},
{
"code": "reportUnknownArgumentType",
"range": {
"startColumn": 42,
"endColumn": 51,
"startColumn": 52,
"endColumn": 61,
"lineCount": 1
}
},
{
"code": "reportUnknownVariableType",
"range": {
"startColumn": 28,
"endColumn": 31,
"startColumn": 24,
"endColumn": 27,
"lineCount": 1
}
},
Expand Down Expand Up @@ -12208,16 +12224,16 @@
{
"code": "reportUnknownArgumentType",
"range": {
"startColumn": 25,
"endColumn": 37,
"startColumn": 26,
"endColumn": 38,
"lineCount": 1
}
},
{
"code": "reportUnknownArgumentType",
"range": {
"startColumn": 39,
"endColumn": 49,
"startColumn": 40,
"endColumn": 50,
"lineCount": 1
}
},
Expand Down Expand Up @@ -13051,126 +13067,6 @@
"lineCount": 1
}
},
{
"code": "reportUnknownParameterType",
"range": {
"startColumn": 29,
"endColumn": 32,
"lineCount": 1
}
},
{
"code": "reportMissingParameterType",
"range": {
"startColumn": 29,
"endColumn": 32,
"lineCount": 1
}
},
{
"code": "reportUnknownParameterType",
"range": {
"startColumn": 34,
"endColumn": 37,
"lineCount": 1
}
},
{
"code": "reportMissingParameterType",
"range": {
"startColumn": 34,
"endColumn": 37,
"lineCount": 1
}
},
{
"code": "reportUnknownMemberType",
"range": {
"startColumn": 7,
"endColumn": 19,
"lineCount": 1
}
},
{
"code": "reportUnknownMemberType",
"range": {
"startColumn": 7,
"endColumn": 24,
"lineCount": 1
}
},
{
"code": "reportUnknownMemberType",
"range": {
"startColumn": 40,
"endColumn": 48,
"lineCount": 1
}
},
{
"code": "reportUnknownMemberType",
"range": {
"startColumn": 7,
"endColumn": 19,
"lineCount": 1
}
},
{
"code": "reportUnknownMemberType",
"range": {
"startColumn": 7,
"endColumn": 24,
"lineCount": 1
}
},
{
"code": "reportUnknownMemberType",
"range": {
"startColumn": 40,
"endColumn": 52,
"lineCount": 1
}
},
{
"code": "reportUnknownArgumentType",
"range": {
"startColumn": 40,
"endColumn": 52,
"lineCount": 1
}
},
{
"code": "reportOptionalOperand",
"range": {
"startColumn": 11,
"endColumn": 23,
"lineCount": 1
}
},
{
"code": "reportOptionalOperand",
"range": {
"startColumn": 13,
"endColumn": 25,
"lineCount": 1
}
},
{
"code": "reportUnknownArgumentType",
"range": {
"startColumn": 71,
"endColumn": 74,
"lineCount": 1
}
},
{
"code": "reportUnknownArgumentType",
"range": {
"startColumn": 76,
"endColumn": 79,
"lineCount": 1
}
},
{
"code": "reportUnknownParameterType",
"range": {
Expand Down
36 changes: 18 additions & 18 deletions contrib/fortran-to-opencl/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,16 @@ class FortranExpressionParser(ExpressionParserBase):
# FIXME double/single prec literals

lex_table: ClassVar[list[tuple[str, str]]] = [
(_less_than, pytools.lex.RE(r"\.lt\.", re.I)),
(_greater_than, pytools.lex.RE(r"\.gt\.", re.I)),
(_less_equal, pytools.lex.RE(r"\.le\.", re.I)),
(_greater_equal, pytools.lex.RE(r"\.ge\.", re.I)),
(_equal, pytools.lex.RE(r"\.eq\.", re.I)),
(_not_equal, pytools.lex.RE(r"\.ne\.", re.I)),

(_not, pytools.lex.RE(r"\.not\.", re.I)),
(_and, pytools.lex.RE(r"\.and\.", re.I)),
(_or, pytools.lex.RE(r"\.or\.", re.I)),
(_less_than, pytools.lex.RE(r"\.lt\.", re.IGNORECASE)),
(_greater_than, pytools.lex.RE(r"\.gt\.", re.IGNORECASE)),
(_less_equal, pytools.lex.RE(r"\.le\.", re.IGNORECASE)),
(_greater_equal, pytools.lex.RE(r"\.ge\.", re.IGNORECASE)),
(_equal, pytools.lex.RE(r"\.eq\.", re.IGNORECASE)),
(_not_equal, pytools.lex.RE(r"\.ne\.", re.IGNORECASE)),

(_not, pytools.lex.RE(r"\.not\.", re.IGNORECASE)),
(_and, pytools.lex.RE(r"\.and\.", re.IGNORECASE)),
(_or, pytools.lex.RE(r"\.or\.", re.IGNORECASE)),
*ExpressionParserBase.lex_table]

def __init__(self, tree_walker):
Expand Down Expand Up @@ -221,7 +221,7 @@ def parse_terminal(self, pstate):
}

def parse_prefix(self, pstate, min_precedence=0):
import pymbolic.primitives as primitives
from pymbolic import primitives
from pymbolic.parser import _PREC_UNARY

pstate.expect_not_end()
Expand Down Expand Up @@ -483,7 +483,7 @@ def __init__(self, translator, scope):

def map_subscript(self, expr, enclosing_prec):
idx_dtype = self.infer_type(expr.index)
if not "i" == idx_dtype.kind or "u" == idx_dtype.kind:
if "i" != idx_dtype.kind or "u" == idx_dtype.kind:
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

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

This condition is logically equivalent to idx_dtype.kind != "i" (the "u" == idx_dtype.kind clause is redundant), which means unsigned integer indices (kind == "u") will always be cast to (int). If the intent is “cast unless the index dtype is an integer (signed or unsigned)”, this should instead check membership (e.g., idx_dtype.kind not in ("i", "u")) to avoid potentially incorrect casts for unsigned indices.

Suggested change
if "i" != idx_dtype.kind or "u" == idx_dtype.kind:
if idx_dtype.kind not in ("i", "u"):

Copilot uses AI. Check for mistakes.
ind_prefix = "(int) "
else:
ind_prefix = ""
Expand Down Expand Up @@ -1383,10 +1383,8 @@ def f2cl(source, free_form=False, strict=True,
source = F2CLTranslator(addr_space_hints, force_casts,
arg_info, use_restrict_pointers=use_restrict_pointers)(tree)

func_decls = []
for entry in source:
if isinstance(entry, cgen.FunctionBody):
func_decls.append(entry.fdecl)
func_decls = [entry.fdecl
for entry in source if isinstance(entry, cgen.FunctionBody)]

mod = cgen.Module([*func_decls, cgen.Line(), *source])

Expand All @@ -1408,8 +1406,10 @@ def f2cl(source, free_form=False, strict=True,


def f2cl_files(source_file, target_file, **kwargs):
mod = f2cl(open(source_file).read(), **kwargs)
open(target_file, "w").write(mod)
with open(source_file) as inf:
mod = f2cl(inf.read(), **kwargs)
with open(target_file, "w") as outf:
outf.write(mod)


if __name__ == "__main__":
Expand Down
Loading
Loading