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

Support python stub files #52

Closed

Conversation

JLLeitschuh
Copy link
Contributor

@JLLeitschuh
Copy link
Contributor Author

Currently seeing this error. It looks like arguments are getting re-ordered, which looks like it's likely a problem outside the scope of this change?

org.opentest4j.AssertionFailedError: [When parsing and printing the source code back to text without modifications, the printed source didn't match the original source code. This means there is a bug in the parser implementation itself. Please open an issue to report this, providing a sample of the code that generated this error!] 
expected: 
  "# Variables with annotations do not need to be assigned a value.
  # So by convention, we omit them in the stub file.
  x: int
  
  # Function bodies cannot be completely removed. By convention,
  # we replace them with `...` instead of the `pass` statement.
  def func_1(code: str) -> int: ...
  
  # We can do the same with default arguments.
  def func_2(a: int, b: int = ...) -> int: ..."
 but was: 
  "# Variables with annotations do not need to be assigned a value.
  # So by convention, we omit them in the stub file.
  x: int
  
  # Function bodies cannot be completely removed. By convention,
  # we replace them with `...` instead of the `pass` statement.
  def func_1(code: str) -> int: ...
  
  # We can do the same with default arguments.
  def func_2(a: int, b = ...: int) -> int: ..."

@sambsnyd sambsnyd requested a review from garyolsen June 5, 2023 16:10
@JLLeitschuh
Copy link
Contributor Author

@garyolsen do you have any insights into why the arguments are getting re-ordered, which is causing the tests to fail? I have no insights here.

@garyolsen
Copy link
Contributor

@JLLeitschuh Yes, this is unrelated—the implementation of type hints in our model is being rendered incorrectly when there is a default value for a parameter.

@JLLeitschuh
Copy link
Contributor Author

Should that get fixed first before this gets merged then? Do you have the cycles to fix that?

@garyolsen
Copy link
Contributor

I think it's fine to merge this first—I won't be able to look at the parsing/printing issue for at least a few days. Just omit the failing test for now and I'll add it back in when I fix the underlying issue.

@traceyyoshima
Copy link
Contributor

Hi @JLLeitschuh! I'm working on adding type attribution to the PythonParser and discovered that the CoreApplicationEnvironment requires the PyiParserDefinition to be configured to work. Issue link.

I'm still sorting out the details about configuring the workspace so that pyi files will resolve correctly, but I expect this PR will result in errors. Can we wait on this until I sort out more details?

@JLLeitschuh
Copy link
Contributor Author

Sure, better to do it right than fast. What's the ETA?

@traceyyoshima
Copy link
Contributor

Sure, better to do it right than fast. What's the ETA?

Thank you - I agree. I created a PythonCoreApplicationEnvironment, but I am still sorting out how to configure dependencies and IntelliJ's virtual file system to resolve types. PYI files are set into a specific workspace, but I need to figure out how that happens. I need a few days to sort out the requirements and will provide an ETA afterward.

@JLLeitschuh
Copy link
Contributor Author

If you've got a plan here, I think I'll close this pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants