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

Allow using an alternative tokenizer #65

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

MatthieuDartiailh
Copy link
Collaborator

I am not sure this approach is the nicest and it looks a bit brittle in places but it would allow to use alternate tokenizers with a well defined interface which would be nice.

Comments welcome !


def __init__(
self, tokengen: Iterator[tokenize.TokenInfo], *, path: str = "", verbose: bool = False
self,
tokengen: Iterator[TokenInfo[TokenType]],
Copy link
Contributor

Choose a reason for hiding this comment

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

why not name it token_generator?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This predate this work so I did not feel like changing it.

line: str


class TokenTypes(Generic[TokenType]):
Copy link
Contributor

@funkyfuture funkyfuture Jun 19, 2022

Choose a reason for hiding this comment

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

the annotations of abstract methods in this class don't result in an exception when they are not implemented as the class doesn't derive from ABC. if that is intended, it should be mentioned, or the methods can raise a NotImplementedError.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in latest commit

@pablogsal
Copy link
Contributor

This needs rebasing 😅

@MatthieuDartiailh
Copy link
Collaborator Author

Rebased but will #71 to pass on 3.10

@MatthieuDartiailh
Copy link
Collaborator Author

Rebased again so that CIs should pass @pablogsal once the 3.11beta5 is live could you review this ?

@MatthieuDartiailh
Copy link
Collaborator Author

@pablogsal I resolved the conflict and hopefully fixed the 3.8 failure. Could you please review ?

@lysnikolaou lysnikolaou force-pushed the main branch 2 times, most recently from 5aae014 to 3cefc85 Compare November 14, 2023 11:58
@0dminnimda
Copy link
Contributor

It would be nice to finally merge this

Comment on lines -245 to -246
if type in exact_token_types:
if tok.type == exact_token_types[type]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be nicer to use hasattr and getattr? Not all objects have dict

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.

4 participants