You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Python: Add type attribution tests, use moduleName for module-qualified FQNs, and fix RemoveImport shadowing (#6798)
* Add type attribution tests and fix method declaration/type hint types
- Add type attribution tests to 13 existing parser test files covering
method invocations, binary ops, type hints, collection literals, imports,
field access, class instances, method declarations, async defs, for loops,
unary ops, ternaries, and lambdas
- Add `method_declaration_type()` to type_mapping.py to build JavaType.Method
for function declarations using ty-types descriptor data with annotation fallback
- Add type attribution to ParameterizedType nodes in type hint expressions
- Fix pre-existing assign_test.py bug (simple_name access, FQN startswith)
- Add typing.Text test to test_type_attribution.py
- Bump ty-types dependency to >=0.0.19.dev20260223093555
* Add parameter field_type attribution and call-site type arguments
- Add param_type_info() to PythonTypeMapping for function parameter
Identifier nodes to get JavaType.Variable field_type
- Update __convert_name() and map_arg() to flow field_type through to
J.Identifier and NamedVariable
- Use call signature returnTypeId for call-site-specific return types
(e.g. int for identity(42) instead of generic T)
- Populate _declared_formal_type_names on method invocation types from
function descriptor type parameters
- Bump ty-types to 0.0.19.dev20260223102528 for callSignature
typeArguments/returnTypeId support
* Use moduleName from ty-types for module-qualified FQNs
classLiteral types now use moduleName to build proper FQNs
(e.g. mymodule.MyClass instead of bare MyClass), and bare
function calls get a declaring type from their module. Bumps
ty-types to 0.0.19.dev20260223122104.
* Address review feedback on type attribution tests
- Extract _ty_types_has_module_name() into shared _markers.py module
to eliminate duplication and reduce subprocess overhead
- Fix temp file leak by adding os.unlink() in finally block
- Fix test_class_instance_type_attribution to accept module-qualified
FQNs (endsWith 'Foo' instead of exact match)
- Gate from-import tests with @requires_module_name since bare function
calls need moduleName for declaring type resolution
- Accept both posixpath and ntpath in os.path test for Windows compat
* Remove skip markers and fix UUID temp filenames for ty-types
Since ty-types minimum version is pinned in pyproject.toml, the
@requires_ty_cli and @requires_module_name skip markers are unnecessary.
Remove them and the shared _markers.py module.
Also prefix UUID-based temp filenames with underscore to ensure they are
valid Python module names — ty-types omits moduleName when the filename
starts with a digit, causing non-deterministic test behavior.
* Use type attribution in RemoveImport to detect shadowed locals
RemoveImport._is_referenced now skips identifiers inside function
scopes that have field_type set, as these are local variables
shadowing the imported name rather than actual uses of the import.
This prevents keeping unused imports when a local variable happens
to share the same name.
Also fix test_type_attribution assertions to accept module-qualified
FQNs (e.g. 'test.Greeter' instead of bare 'Greeter') since the
moduleName improvements now produce module-prefixed names.
0 commit comments