Skip to content

💊 Optimize Python >=3.8 type comments support method i90.#95

Merged
isidentical merged 3 commits intohakancelikdev:masterfrom
hadialqattan:i90
Sep 12, 2020
Merged

💊 Optimize Python >=3.8 type comments support method i90.#95
isidentical merged 3 commits intohakancelikdev:masterfrom
hadialqattan:i90

Conversation

@hadialqattan
Copy link
Contributor

No description provided.

@hadialqattan hadialqattan mentioned this pull request Sep 10, 2020
Copy link
Collaborator

@isidentical isidentical left a comment

Choose a reason for hiding this comment

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

Instead of trying version check on every possible node, you can just create a function named def _type_comment(node: ast.AST) -> None which does the job by using getattr, not the version check, since we might switch to typed_ast to use this feature on all possible versions. Example;

def type_comment(node: ast.AST) -> None:
      if isinstance(node, ASTFunctionT): mode="func_type"
      else: mode="eval"
      type_comment = getattr(node, "type_comment", None)
      if type_comment is not None: ....

@hadialqattan
Copy link
Contributor Author

Instead of trying version check on every possible node, you can just create a function named def _type_comment(node: ast.AST) -> None which does the job by using getattr, not the version check, since we might switch to typed_ast to use this feature on all possible versions. Example;

def type_comment(node: ast.AST) -> None:
      if isinstance(node, ASTFunctionT): mode="func_type"
      else: mode="eval"
      type_comment = getattr(node, "type_comment", None)
      if type_comment is not None: ....

I agree with you!

@isidentical
Copy link
Collaborator

By the way, do you like to join our telegram group?

@hadialqattan
Copy link
Contributor Author

By the way, do you like to join our telegram group?

Of course!

@hadialqattan
Copy link
Contributor Author

By the way, do you like to join our telegram group?

Of course!

I hope it's an English group because I can't speak Turkish!

@isidentical
Copy link
Collaborator

I hope it's an English group because I can't speak Turkish!

Indeed!

@hadialqattan
Copy link
Contributor Author

I hope it's an English group because I can't speak Turkish!

Indeed!

Ok, so please send the invitation link to alqattanhadizaki@gmail.com

@hakancelikdev
Copy link
Owner

I hope it's an English group because I can't speak Turkish!

Indeed!

Ok, so please send the invitation link to alqattanhadizaki@gmail.com

You are in the group, check the telegram.

@hadialqattan
Copy link
Contributor Author

I hope it's an English group because I can't speak Turkish!

Indeed!

Ok, so please send the invitation link to alqattanhadizaki@gmail.com

You are in the group, check the telegram.

Thanks a lot!

@isidentical isidentical merged commit db4eb3e into hakancelikdev:master Sep 12, 2020
@hadialqattan hadialqattan deleted the i90 branch September 12, 2020 10:07
@hakancelikdev hakancelikdev linked an issue Sep 12, 2020 that may be closed by this pull request
hakancelikdev pushed a commit that referenced this pull request Jul 16, 2022
* 💊 Optimize Python >=3.8 type comments support method

* getattr instead of version check.

* Make ASTFunctionT global.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Poor performance.

3 participants