You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/04/14 12:03:32 UTC
[GitHub] [airflow] potiuk commented on a diff in pull request #23012: Fallback Provider's doc URL to "Documentation" meta-data
potiuk commented on code in PR #23012:
URL: https://github.com/apache/airflow/pull/23012#discussion_r850374416
##########
airflow/utils/docs.py:
##########
@@ -35,4 +40,20 @@ def get_docs_url(page: Optional[str] = None) -> str:
def get_doc_url_for_provider(provider_name: str, provider_version: str) -> str:
"""Prepare link to Airflow Provider documentation."""
- return f'https://airflow.apache.org/docs/{provider_name}/{provider_version}/'
+ try:
+ metadata_items = importlib_metadata.metadata(provider_name).get_all("Project-URL")
+ if isinstance(metadata_items, str):
Review Comment:
Warning! Rant:
Who on earth came with the interface to importlib's metadata ????
1) when you do ['Project-URL'] - you get only the first matching entry in "project-URL"
2) when you do get_all() - you get all, normally when you get many, you get list, but when you ave one - you get string (WtF?)
3) Even if metadata in setup.py/cfg/pyproject.toml is structured, the "string" you get here is coma separated entry ("type, value")
4) The PEP 0621: https://peps.python.org/pep-0621/#example shows example of documentation metadata as:
```
[project.urls]
homepage = "example.com"
documentation = "readthedocs.org"
repository = "github.com"
changelog = "github.com/me/spam/blob/master/CHANGELOG.md"
```
Yet - you have to ue "Prioject-URL" and you get "Documentaiton" as output.
```
##########
airflow/utils/docs.py:
##########
@@ -35,4 +40,20 @@ def get_docs_url(page: Optional[str] = None) -> str:
def get_doc_url_for_provider(provider_name: str, provider_version: str) -> str:
"""Prepare link to Airflow Provider documentation."""
- return f'https://airflow.apache.org/docs/{provider_name}/{provider_version}/'
+ try:
+ metadata_items = importlib_metadata.metadata(provider_name).get_all("Project-URL")
+ if isinstance(metadata_items, str):
Review Comment:
Warning! Rant:
Who on earth came with the interface to importlib's metadata ????
1) when you do ['Project-URL'] - you get only the first matching entry in "project-URL"
2) when you do get_all() - you get all, normally when you get many, you get list, but when you ave one - you get string (WtF?)
3) Even if metadata in setup.py/cfg/pyproject.toml is structured, the "string" you get here is coma separated entry ("type, value")
4) The PEP 0621: https://peps.python.org/pep-0621/#example shows example of documentation metadata as:
```
[project.urls]
homepage = "example.com"
documentation = "readthedocs.org"
repository = "github.com"
changelog = "github.com/me/spam/blob/master/CHANGELOG.md"
```
Yet - you have to ue "Prioject-URL" and you get "Documentaiton" as output.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org