Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: Please add support for other class names too. #172

Open
sairam4123 opened this issue Jul 10, 2020 · 2 comments
Open

Python: Please add support for other class names too. #172

sairam4123 opened this issue Jul 10, 2020 · 2 comments
Labels
enhancement good first issue Issue that is relatively easy to implement

Comments

@sairam4123
Copy link

I am trying to add a converters like this:

.int : Convert into int
    ANY -> int($expr$)$END$
.str : Convert into str
    ANY -> str($expr$)$END$
.frozenset : Convert into frozenset
    list -> frozenset($expr$)$END$
    tuple -> frozenset($expr$)$END$
    set -> frozenset($expr$)$END$
    dict -> frozenset($expr$)$END$
.set : Convert into set
    ANY -> set($expr$)$END$
.list : Convert into list
    ANY -> list($expr$)$END$
.dict : Convert into dict
    ANY -> dict($expr$)$END$
.tuple : Convert into tuple
    ANY -> tuple($expr$)$END$
.bool : Convert into bool
    ANY -> bool($expr$)$END$
.frozenset : Convert into frozenset
    list -> frozenset($expr$)$END$
    tuple -> frozenset($expr$)$END$
    set -> frozenset($expr$)$END$
    dict -> frozenset($expr$)$END$

this can be simplified even further using like this

.frozenset : Convert into frozenset
    iter -> frozenset($expr$)$END$

But as there's no class like iterable in Postfix here.
So, the workaround would be this:

.frozenset : Convert into frozenset
    list -> frozenset($expr$)$END$
    tuple -> frozenset($expr$)$END$
    set -> frozenset($expr$)$END$
    dict -> frozenset($expr$)$END$

So it would be nice if you add support for other classes too.
like frozenset, iter, ...
Thank you!

@xylo xylo added good first issue Issue that is relatively easy to implement enhancement labels Aug 4, 2020
ikopysov added a commit to ikopysov/intellij-postfix-templates that referenced this issue Oct 30, 2020
Implemented complex types which can contain multiple types.
Change how type names are retrieved, because previous approach created incorrect names for tuples, e.g.: (1,2,3) were (int, int, int) and not tuple.

WIP: New type names should be tested, maybe they will provide wrong results for objects
@ikopysov
Copy link
Contributor

I've added support for frozenset type and introduced "complex" types, which can include multiple types, like "iter" mentioned by you.

It's not really flexible, and it may be possible to implement checks for the type methods

It seems tuples currently are not working due to their names being different, e.g.: according to documentation, iterator should have iter method.
But this feature is quite large.

Also, it seems the "tuple" type is not detected correctly (for the entire Python CPT):
(1, 2, 3) will have (int, int, int) type name, but "tuple" is expected.
I'm trying to get the correct name differently, but it should be tested.

@sairam4123
Copy link
Author

Is there any progress on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement good first issue Issue that is relatively easy to implement
Projects
None yet
Development

No branches or pull requests

3 participants