Add pyrefly suppressions
PiperOrigin-RevId: 966501583 Change-Id: I942ec198b369fb4a2f430070ee1002e7ad2d0c9d
This commit is contained in:
committed by
Copybara-Service
parent
06aa6c075f
commit
e3590b7449
@@ -71,7 +71,7 @@ class ApiState:
|
|||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
def export_definition(self):
|
def export_definition(self):
|
||||||
return ApiDefinition(self.token, self._state, self.code, self._start,
|
return ApiDefinition(self.token, self._state, self.code, self._start, # pyrefly: ignore[bad-argument-type]
|
||||||
self._end, self.section, self.doc)
|
self._end, self.section, self.doc)
|
||||||
|
|
||||||
def start(self, state):
|
def start(self, state):
|
||||||
|
|||||||
@@ -277,7 +277,7 @@ def _lex(text: str, path: str) -> tuple[list[_Token], dict[int, str]]:
|
|||||||
elif kind == 'punct':
|
elif kind == 'punct':
|
||||||
tokens.append(_Token(value, value, line))
|
tokens.append(_Token(value, value, line))
|
||||||
elif kind != 'ws':
|
elif kind != 'ws':
|
||||||
tokens.append(_Token(kind, value, line))
|
tokens.append(_Token(kind, value, line)) # pyrefly: ignore[bad-argument-type]
|
||||||
pos = match.end()
|
pos = match.end()
|
||||||
tokens.append(_Token('eof', '', line))
|
tokens.append(_Token('eof', '', line))
|
||||||
return tokens, comments
|
return tokens, comments
|
||||||
@@ -686,7 +686,7 @@ def _validate_attr(schema: Schema, attr: Attr, namespaces: set[str]):
|
|||||||
numeric and isinstance(attr.facets[facet], (int, float))):
|
numeric and isinstance(attr.facets[facet], (int, float))):
|
||||||
err(f'facet {facet!r} requires a numeric attribute and value')
|
err(f'facet {facet!r} requires a numeric attribute and value')
|
||||||
if 'min' in attr.facets and 'max' in attr.facets:
|
if 'min' in attr.facets and 'max' in attr.facets:
|
||||||
if attr.facets['min'] > attr.facets['max']:
|
if attr.facets['min'] > attr.facets['max']: # pyrefly: ignore[unsupported-operation]
|
||||||
err("facet 'min' cannot be greater than 'max'")
|
err("facet 'min' cannot be greater than 'max'")
|
||||||
if attr.facets.get('positive') and not numeric:
|
if attr.facets.get('positive') and not numeric:
|
||||||
err("facet 'positive' requires a numeric attribute")
|
err("facet 'positive' requires a numeric attribute")
|
||||||
@@ -699,7 +699,7 @@ def _validate_attr(schema: Schema, attr: Attr, namespaces: set[str]):
|
|||||||
if attr.type == 'enum':
|
if attr.type == 'enum':
|
||||||
if not isinstance(attr.default, str):
|
if not isinstance(attr.default, str):
|
||||||
err(f'default for enum attribute {attr.name!r} must be a keyword')
|
err(f'default for enum attribute {attr.name!r} must be a keyword')
|
||||||
keywords = schema.enums[attr.target].keywords()
|
keywords = schema.enums[attr.target].keywords() # pyrefly: ignore[bad-index]
|
||||||
if attr.default not in keywords:
|
if attr.default not in keywords:
|
||||||
err(f'default {attr.default!r} is not a keyword of enum '
|
err(f'default {attr.default!r} is not a keyword of enum '
|
||||||
f'{attr.target!r}')
|
f'{attr.target!r}')
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ def _generate_field_data(
|
|||||||
# Note: Manually handled MjModel fields are special cased so that a
|
# Note: Manually handled MjModel fields are special cased so that a
|
||||||
# by-reference embind return value policy is used.
|
# by-reference embind return value policy is used.
|
||||||
return WrappedFieldData(
|
return WrappedFieldData(
|
||||||
typename=_get_field_struct_type(f, s),
|
typename=_get_field_struct_type(f, s), # pyrefly: ignore[bad-argument-type]
|
||||||
declaration=f"// {f.name} field is handled manually in template file struct declaration", # pylint: disable=line-too-long
|
declaration=f"// {f.name} field is handled manually in template file struct declaration", # pylint: disable=line-too-long
|
||||||
binding=_get_property_binding(f, w, reference=(w == "MjModel")),
|
binding=_get_property_binding(f, w, reference=(w == "MjModel")),
|
||||||
)
|
)
|
||||||
@@ -115,7 +115,7 @@ def _generate_field_data(
|
|||||||
|
|
||||||
return WrappedFieldData(
|
return WrappedFieldData(
|
||||||
declaration=builder.to_string(),
|
declaration=builder.to_string(),
|
||||||
typename=_get_field_struct_type(f, s),
|
typename=_get_field_struct_type(f, s), # pyrefly: ignore[bad-argument-type]
|
||||||
binding=_get_property_binding(f, w, setter=True, reference=True),
|
binding=_get_property_binding(f, w, setter=True, reference=True),
|
||||||
is_primitive_or_fixed_size=True,
|
is_primitive_or_fixed_size=True,
|
||||||
)
|
)
|
||||||
@@ -123,7 +123,7 @@ def _generate_field_data(
|
|||||||
elif isinstance(f.type, ast_nodes.ValueType) and f.type.name.startswith("mj"):
|
elif isinstance(f.type, ast_nodes.ValueType) and f.type.name.startswith("mj"):
|
||||||
return WrappedFieldData(
|
return WrappedFieldData(
|
||||||
declaration=f"{common.capitalize(f.type.name)} {f.name};",
|
declaration=f"{common.capitalize(f.type.name)} {f.name};",
|
||||||
typename=_get_field_struct_type(f, s),
|
typename=_get_field_struct_type(f, s), # pyrefly: ignore[bad-argument-type]
|
||||||
binding=_get_property_binding(f, w, setter=False, reference=True),
|
binding=_get_property_binding(f, w, setter=False, reference=True),
|
||||||
ptr_initialization=f"{f.name}(&ptr_->{f.name})",
|
ptr_initialization=f"{f.name}(&ptr_->{f.name})",
|
||||||
ptr_copy_reset=f"{f.name}.set(&ptr_->{f.name});",
|
ptr_copy_reset=f"{f.name}.set(&ptr_->{f.name});",
|
||||||
@@ -134,9 +134,9 @@ def _generate_field_data(
|
|||||||
anonymous_struct_name = _get_field_struct_type(f, s)
|
anonymous_struct_name = _get_field_struct_type(f, s)
|
||||||
return WrappedFieldData(
|
return WrappedFieldData(
|
||||||
binding=_get_property_binding(f, w, setter=False, reference=True),
|
binding=_get_property_binding(f, w, setter=False, reference=True),
|
||||||
typename=anonymous_struct_name,
|
typename=anonymous_struct_name, # pyrefly: ignore[bad-argument-type]
|
||||||
declaration=(
|
declaration=(
|
||||||
f"{common.wrapped_struct_name(anonymous_struct_name)} {f.name};"
|
f"{common.wrapped_struct_name(anonymous_struct_name)} {f.name};" # pyrefly: ignore[bad-argument-type]
|
||||||
),
|
),
|
||||||
ptr_initialization=f"{f.name}(&ptr_->{f.name})",
|
ptr_initialization=f"{f.name}(&ptr_->{f.name})",
|
||||||
ptr_copy_reset=f"{f.name}.set(&ptr_->{f.name});",
|
ptr_copy_reset=f"{f.name}.set(&ptr_->{f.name});",
|
||||||
@@ -173,7 +173,7 @@ def _generate_field_data(
|
|||||||
|
|
||||||
return WrappedFieldData(
|
return WrappedFieldData(
|
||||||
declaration=builder.to_string(),
|
declaration=builder.to_string(),
|
||||||
typename=_get_field_struct_type(f, s),
|
typename=_get_field_struct_type(f, s), # pyrefly: ignore[bad-argument-type]
|
||||||
binding=_get_property_binding(f, w),
|
binding=_get_property_binding(f, w),
|
||||||
is_primitive_or_fixed_size=True,
|
is_primitive_or_fixed_size=True,
|
||||||
)
|
)
|
||||||
@@ -183,7 +183,7 @@ def _generate_field_data(
|
|||||||
f"std::vector<{common.capitalize(inner_type_name)}> {f.name};"
|
f"std::vector<{common.capitalize(inner_type_name)}> {f.name};"
|
||||||
),
|
),
|
||||||
ptr_initialization=f"{f.name}(&ptr_->{f.name})",
|
ptr_initialization=f"{f.name}(&ptr_->{f.name})",
|
||||||
typename=_get_field_struct_type(f, s),
|
typename=_get_field_struct_type(f, s), # pyrefly: ignore[bad-argument-type]
|
||||||
binding=_get_property_binding(f, w, reference=True),
|
binding=_get_property_binding(f, w, reference=True),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@ def _generate_field_data(
|
|||||||
builder.line(f"*(ptr_->{f.name}) = value;")
|
builder.line(f"*(ptr_->{f.name}) = value;")
|
||||||
return WrappedFieldData(
|
return WrappedFieldData(
|
||||||
declaration=builder.to_string(),
|
declaration=builder.to_string(),
|
||||||
typename=_get_field_struct_type(f, s),
|
typename=_get_field_struct_type(f, s), # pyrefly: ignore[bad-argument-type]
|
||||||
binding=_get_property_binding(f, w, setter=True, reference=True),
|
binding=_get_property_binding(f, w, setter=True, reference=True),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -225,7 +225,7 @@ def _generate_field_data(
|
|||||||
builder.line(f"return {ptr_field_expr_vec};")
|
builder.line(f"return {ptr_field_expr_vec};")
|
||||||
return WrappedFieldData(
|
return WrappedFieldData(
|
||||||
declaration=builder.to_string(),
|
declaration=builder.to_string(),
|
||||||
typename=_get_field_struct_type(f, s),
|
typename=_get_field_struct_type(f, s), # pyrefly: ignore[bad-argument-type]
|
||||||
binding=_get_property_binding(f, w, setter=False, reference=True),
|
binding=_get_property_binding(f, w, setter=False, reference=True),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -235,7 +235,7 @@ def _generate_field_data(
|
|||||||
and not is_dynamically_sized
|
and not is_dynamically_sized
|
||||||
):
|
):
|
||||||
builder = code_builder.CodeBuilder()
|
builder = code_builder.CodeBuilder()
|
||||||
if f.type.inner_type.is_const:
|
if f.type.inner_type.is_const: # pyrefly: ignore[missing-attribute]
|
||||||
with builder.function(f"std::string {f.name}() const"):
|
with builder.function(f"std::string {f.name}() const"):
|
||||||
builder.line(
|
builder.line(
|
||||||
f'return ptr_->{f.name} ? std::string(ptr_->{f.name}) : "";'
|
f'return ptr_->{f.name} ? std::string(ptr_->{f.name}) : "";'
|
||||||
@@ -253,7 +253,7 @@ def _generate_field_data(
|
|||||||
)
|
)
|
||||||
return WrappedFieldData(
|
return WrappedFieldData(
|
||||||
declaration=builder.to_string(),
|
declaration=builder.to_string(),
|
||||||
typename=_get_field_struct_type(f, s),
|
typename=_get_field_struct_type(f, s), # pyrefly: ignore[bad-argument-type]
|
||||||
binding=_get_property_binding(
|
binding=_get_property_binding(
|
||||||
f, w, setter=not f.type.inner_type.is_const, reference=True
|
f, w, setter=not f.type.inner_type.is_const, reference=True
|
||||||
),
|
),
|
||||||
@@ -273,7 +273,7 @@ def _generate_field_data(
|
|||||||
)
|
)
|
||||||
return WrappedFieldData(
|
return WrappedFieldData(
|
||||||
declaration=f"{wrapper_field_name} {f.name};",
|
declaration=f"{wrapper_field_name} {f.name};",
|
||||||
typename=_get_field_struct_type(f, s),
|
typename=_get_field_struct_type(f, s), # pyrefly: ignore[bad-argument-type]
|
||||||
binding=_get_property_binding(f, w, setter=False, reference=True),
|
binding=_get_property_binding(f, w, setter=False, reference=True),
|
||||||
ptr_initialization=f"{f.name}(ptr_->{f.name})",
|
ptr_initialization=f"{f.name}(ptr_->{f.name})",
|
||||||
)
|
)
|
||||||
@@ -284,7 +284,7 @@ def _generate_field_data(
|
|||||||
ptr_field_expr = f"ptr_->{f.name}"
|
ptr_field_expr = f"ptr_->{f.name}"
|
||||||
array_size_str = ""
|
array_size_str = ""
|
||||||
if is_dynamically_sized:
|
if is_dynamically_sized:
|
||||||
array_size_str = parse_array_extent(f.array_extent, w, f.name)
|
array_size_str = parse_array_extent(f.array_extent, w, f.name) # pyrefly: ignore[bad-argument-type]
|
||||||
elif f.name in constants.BYTE_FIELDS.keys():
|
elif f.name in constants.BYTE_FIELDS.keys():
|
||||||
# For byte fields, we need to cast the pointer to uint8_t*
|
# For byte fields, we need to cast the pointer to uint8_t*
|
||||||
# so embind can correctly interpret the memory view
|
# so embind can correctly interpret the memory view
|
||||||
@@ -303,7 +303,7 @@ def _generate_field_data(
|
|||||||
)
|
)
|
||||||
return WrappedFieldData(
|
return WrappedFieldData(
|
||||||
declaration=builder.to_string(),
|
declaration=builder.to_string(),
|
||||||
typename=_get_field_struct_type(f, s),
|
typename=_get_field_struct_type(f, s), # pyrefly: ignore[bad-argument-type]
|
||||||
binding=_get_property_binding(f, w),
|
binding=_get_property_binding(f, w),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -711,7 +711,7 @@ def _get_anonymous_struct_field(
|
|||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
return target_field
|
return target_field # pyrefly: ignore[bad-return]
|
||||||
|
|
||||||
|
|
||||||
def _get_field_struct_type(
|
def _get_field_struct_type(
|
||||||
|
|||||||
Reference in New Issue
Block a user