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

Wrap indent docstring in newlines for UnionSnippet #777

Merged
merged 7 commits into from
Feb 7, 2024

Conversation

LorenzoMartini
Copy link
Contributor

@LorenzoMartini LorenzoMartini commented Feb 6, 2024

Before this PR

The UnionSnippet.emit(PythonPoetWriter poetWriter) method parses conjure class definitions into python code bindings. As part of the process, it extracts docs components from the apis and wraps them in the python docstring format, which is the triple-quote """.

If a docstring terminates with a " (which it shouldn't), that would cause a set of 4 consecutives ", which is invalid python and that will cause errors when reading from these files.
For example, if I define my conjure api like

FaultyType:
  docs: this will say "ERROR"
  union:
    something: integer
    somethingElse: string

this will cause the following error when reading the generated conjure python bindings:

File "tmp.py", line 10
      """this will say "ERROR""""
                                                  ^
  SyntaxError: EOL while scanning string literal

After this PR

Fix up UnionSnippet to have newlines wrapping the content and extract the doc-writing into a separate method being reused across all cases.

==COMMIT_MSG==
Wrap indent docstring in newlines for UnionSnippet
==COMMIT_MSG==

Possible downsides?

The pythonic way of doing docstrings has them in the format

"""Docstring
"""

but we currently do

"""
Docstring
"""

I will change that in a separate PR, this is a more time-sensitive fix.

@changelog-app
Copy link

changelog-app bot commented Feb 6, 2024

Generate changelog in changelog/@unreleased

What do the change types mean?
  • feature: A new feature of the service.
  • improvement: An incremental improvement in the functionality or operation of the service.
  • fix: Remedies the incorrect behaviour of a component of the service in a backwards-compatible way.
  • break: Has the potential to break consumers of this service's API, inclusive of both Palantir services
    and external consumers of the service's API (e.g. customer-written software or integrations).
  • deprecation: Advertises the intention to remove service functionality without any change to the
    operation of the service itself.
  • manualTask: Requires the possibility of manual intervention (running a script, eyeballing configuration,
    performing database surgery, ...) at the time of upgrade for it to succeed.
  • migration: A fully automatic upgrade migration task with no engineer input required.

Note: only one type should be chosen.

How are new versions calculated?
  • ❗The break and manual task changelog types will result in a major release!
  • 🐛 The fix changelog type will result in a minor release in most cases, and a patch release version for patch branches. This behaviour is configurable in autorelease.
  • ✨ All others will result in a minor version release.

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Wrap indent docstring in newlines for UnionSnippet

Check the box to generate changelog(s)

  • Generate changelog entry

@LorenzoMartini LorenzoMartini changed the title Wrap indent docstring in trailing newline for PythonService Wrap indent docstring in trailing newline for UnionSnippet Feb 6, 2024
@LorenzoMartini LorenzoMartini changed the title Wrap indent docstring in trailing newline for UnionSnippet Wrap indent docstring in newlines for UnionSnippet Feb 6, 2024
@LorenzoMartini
Copy link
Contributor Author

Failing on unrelated stuff due to develop of this repo being broken

@johnhany97
Copy link
Member

Issue that's currently blocking this is fixed in #778

@johnhany97
Copy link
Member

👍

@bulldozer-bot bulldozer-bot bot merged commit 97121e7 into develop Feb 7, 2024
6 checks passed
@bulldozer-bot bulldozer-bot bot deleted the lmartini/quotes branch February 7, 2024 12:04
@svc-autorelease
Copy link
Collaborator

Released 4.10.0

LorenzoMartini added a commit that referenced this pull request Feb 7, 2024
Wrap indent docstring in newlines for UnionSnippet
johnhany97 pushed a commit that referenced this pull request Feb 7, 2024
Wrap indent docstring in newlines for UnionSnippet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants