Skip to content

Commit c5e37a6

Browse files
author
esblinov
committed
Improve some typing
1 parent 38ad864 commit c5e37a6

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343

4444
- name: Run mypy
4545
shell: bash
46-
run: mypy --check transfunctions
46+
run: mypy transfunctions
4747

4848
- name: Run mypy for tests
4949
shell: bash

transfunctions/transformer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def extract_context(self, context_name: str, addictional_transformers: Optional[
175175
converted_source_code = self.clear_spaces_from_source_code(source_code)
176176
tree = parse(converted_source_code)
177177
original_function = self.function
178-
transfunction_decorator = None
178+
transfunction_decorator: Optional[Name] = None
179179
decorator_name = self.decorator_name
180180

181181
class RewriteContexts(NodeTransformer):
@@ -213,7 +213,7 @@ def visit_FunctionDef(self, node: FunctionDef) -> Optional[Union[AST, List[AST]]
213213
else:
214214
if transfunction_decorator is not None:
215215
raise DualUseOfDecoratorError(f"You cannot use the @{decorator_name} decorator twice for the same function.")
216-
transfunction_decorator = decorator
216+
transfunction_decorator = cast(Name, decorator)
217217

218218
node.decorator_list = []
219219
return node
@@ -236,9 +236,9 @@ def visit_FunctionDef(self, node: FunctionDef) -> Optional[Union[AST, List[AST]]
236236
tree = self.wrap_ast_by_closures(tree)
237237

238238
if version_info.minor > 10:
239-
increment_lineno(tree, n=(self.decorator_lineno - transfunction_decorator.lineno))
239+
increment_lineno(tree, n=(self.decorator_lineno - cast(Name, transfunction_decorator).lineno))
240240
else:
241-
increment_lineno(tree, n=(self.decorator_lineno - transfunction_decorator.lineno - 1))
241+
increment_lineno(tree, n=(self.decorator_lineno - cast(Name, transfunction_decorator).lineno - 1))
242242

243243
code = compile(tree, filename=getfile(self.function), mode='exec')
244244
namespace = UniversalNamespaceAroundFunction(self.function, self.frame)

0 commit comments

Comments
 (0)