Skip to content

Add code snippet formatting in docstrings via Ruff#36262

Merged
potiuk merged 1 commit intoapache:mainfrom
josh-fell:ruff-format-code-docs
Dec 17, 2023
Merged

Add code snippet formatting in docstrings via Ruff#36262
potiuk merged 1 commit intoapache:mainfrom
josh-fell:ruff-format-code-docs

Conversation

@josh-fell
Copy link
Contributor

This was made available as part of v0.1.8 of the Ruff Formatter. Adding this config option to the ruff-format pre-commit hook.

@josh-fell
Copy link
Contributor Author

josh-fell commented Dec 17, 2023

This might also remove the need for blacken-docs inferring from this comment from the release notes of what this new version of Ruff Formatter supports:

reStructuredText code-block and sourcecode directives. As with Markdown, the language names recognized for Python are python, py, python3, or py3.

Am I reading that correctly?

@potiuk
Copy link
Member

potiuk commented Dec 17, 2023

Am I reading that correctly?

You can check it by wrong-formating some of those :)

This was made available [as part of v0.1.8 of the Ruff Formatter](https://astral.sh/blog/ruff-v0.1.8#formatting-code-snippets-in-docstrings). Adding this config option to the `ruff-format` pre-commit hook.
@josh-fell josh-fell force-pushed the ruff-format-code-docs branch from 46eeff2 to 5992279 Compare December 17, 2023 15:21
@josh-fell
Copy link
Contributor Author

This might also remove the need for blacken-docs inferring from this comment from the release notes of what this new version of Ruff Formatter supports:

reStructuredText code-block and sourcecode directives. As with Markdown, the language names recognized for Python are python, py, python3, or py3.

Am I reading that correctly?

Nope just handles those directives in docstrings not in rST files. Maybe one day.

Copy link
Member

@hussein-awala hussein-awala left a comment

Choose a reason for hiding this comment

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

Great one! I was planning to test it once I have some time.

@potiuk potiuk merged commit e9ba37b into apache:main Dec 17, 2023
@josh-fell josh-fell deleted the ruff-format-code-docs branch December 17, 2023 18:31
potiuk pushed a commit that referenced this pull request Dec 30, 2023
This was made available [as part of v0.1.8 of the Ruff Formatter](https://astral.sh/blog/ruff-v0.1.8#formatting-code-snippets-in-docstrings). Adding this config option to the `ruff-format` pre-commit hook.

(cherry picked from commit e9ba37b)
@potiuk potiuk added this to the Airflow 2.8.1 milestone Dec 30, 2023
@potiuk potiuk added area:dev-env CI, pre-commit, pylint and other changes that do not change the behavior of the final code changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) labels Dec 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dev-env CI, pre-commit, pylint and other changes that do not change the behavior of the final code area:providers changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) provider:amazon AWS/Amazon - related issues provider:apache-cassandra provider:apache-hive provider:cncf-kubernetes Kubernetes (k8s) provider related issues provider:databricks provider:ftp provider:google Google (including GCP) related issues provider:microsoft-azure Azure-related issues provider:sftp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants