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

Refactor semantic analyzer #4083

Closed
JukkaL opened this issue Oct 9, 2017 · 6 comments
Closed

Refactor semantic analyzer #4083

JukkaL opened this issue Oct 9, 2017 · 6 comments
Labels

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Oct 9, 2017

The current semantic analyzer is hard to understand and modify. Here some ideas for how to improve things:

  • Create separate modules for the three different passes (say, mypy.analyzer[123]).
  • Don't pass a SemanticAnalyzer instance to the first and third passes. Instead, move any shared functionality to a utility class (or functions), and put them in a separate module such as mypy.analyzeutil.
  • Rename the passes to, say, SemanticAnalyzerPass[123].
@ilevkivskyi ilevkivskyi added refactoring Changing mypy's internals size-large labels Oct 9, 2017
@emmatyping
Copy link
Collaborator

Should we close #3459 in favor of this? Or close this in favor of that?

@ilevkivskyi
Copy link
Member

We can keep #3459 to track documenting part, which is not mentioned here, but I leave this up to @JukkaL to decide.

@elazarg
Copy link
Contributor

elazarg commented Oct 10, 2017

Also

  • We can try (again) to extract the creation of namedtuple, typeddict etc. to a separate module
  • The analysis of a class can follow the interpreter: first analyzing the body, then passing the results to a "meta" function that constructs the class object. This will be cleaner, and a good plugin point (e.g. for special classes)

@emmatyping
Copy link
Collaborator

I think this issue could use an update since there has been a lot of progress on this :) I believe we still want to not pass the second pass' instance to the first pass, but are there other concrete steps left in this issue?

@JukkaL
Copy link
Collaborator Author

JukkaL commented Apr 10, 2018

Here's what has been done:

  • Semantic analysis passes have been moved to different modules and they have documentation.
  • Named tuple, TypedDict, NewType and call-based Enum have been moved to new modules.

The main missing thing is getting rid of direct references between passes.

@JukkaL
Copy link
Collaborator Author

JukkaL commented Jan 16, 2019

Closed in favor of #6204, which has a wider scope.

@JukkaL JukkaL closed this as completed Jan 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants