|
60 | 60 |
|
61 | 61 | class TaskOnKartPlugin(Plugin): |
62 | 62 | def get_base_class_hook(self, fullname: str) -> Callable[[ClassDefContext], None] | None: |
63 | | - if 'gokart.task.luigi.Task' in fullname: |
64 | | - # gather attibutes from gokart.TaskOnKart |
65 | | - # the transformation does not affect because the class has `__init__` method |
| 63 | + # The following gathers attributes from gokart.TaskOnKart such as `workspace_directory` |
| 64 | + # the transformation does not affect because the class has `__init__` method of `gokart.TaskOnKart`. |
| 65 | + # |
| 66 | + # NOTE: `gokart.task.luigi.Task` condition is required for the release of luigi versions without py.typed |
| 67 | + if fullname in {'gokart.task.luigi.Task', 'luigi.task.Task'}: |
66 | 68 | return self._task_on_kart_class_maker_callback |
67 | 69 |
|
68 | 70 | sym = self.lookup_fully_qualified(fullname) |
@@ -209,7 +211,6 @@ def transform(self) -> bool: |
209 | 211 | if ('__init__' not in info.names or info.names['__init__'].plugin_generated) and attributes: |
210 | 212 | args = [attr.to_argument(info, of='__init__') for attr in attributes] |
211 | 213 | add_method_to_class(self._api, self._cls, '__init__', args=args, return_type=NoneType()) |
212 | | - |
213 | 214 | info.metadata[METADATA_TAG] = { |
214 | 215 | 'attributes': [attr.serialize() for attr in attributes], |
215 | 216 | } |
@@ -330,6 +331,7 @@ def collect_attributes(self) -> Optional[list[TaskOnKartAttribute]]: |
330 | 331 | info=cls.info, |
331 | 332 | api=self._api, |
332 | 333 | ) |
| 334 | + |
333 | 335 | return list(found_attrs.values()) |
334 | 336 |
|
335 | 337 | def _collect_parameter_args(self, expr: Expression) -> tuple[bool, dict[str, Expression]]: |
@@ -404,9 +406,13 @@ def is_parameter_call(expr: Expression) -> bool: |
404 | 406 | type_info = callee.node |
405 | 407 | if type_info is None and isinstance(callee.expr, NameExpr): |
406 | 408 | return PARAMETER_FULLNAME_MATCHER.match(f'{callee.expr.name}.{callee.name}') is not None |
407 | | - if isinstance(type_info, TypeInfo) and PARAMETER_FULLNAME_MATCHER.match(type_info.fullname): |
408 | | - return True |
| 409 | + elif isinstance(callee, NameExpr): |
| 410 | + type_info = callee.node |
| 411 | + else: |
409 | 412 | return False |
| 413 | + |
| 414 | + if isinstance(type_info, TypeInfo): |
| 415 | + return PARAMETER_FULLNAME_MATCHER.match(type_info.fullname) is not None |
410 | 416 | return False |
411 | 417 |
|
412 | 418 |
|
|
0 commit comments