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

Remove :type lines now sphinx-autoapi supports typehints #20951

Merged
merged 2 commits into from
Jan 20, 2022

Conversation

ashb
Copy link
Member

@ashb ashb commented Jan 19, 2022

Since we have no updated sphinx-autoapi to a more recent version it supports showing type hints in the documentation, so we don't need to have the type hints and the :type lines -- which is good, as the ones in the doc strings are easy to get out of date!

The following settings have been set:

  • autodoc_typehints = 'description' -- show types in description (where previous :type used to show up)

  • autodoc_typehints_description_target = 'documented' -- only link to types that are documented. (Without this we have some missing return types that aren't documented, and aren't linked to in our current python API docs, so this caused a build failure)

  • autodoc_typehints_format = 'short' -- Shorten type hints where possible, i.e. StringIO instead of io.StringIO

Before (https://airflow.apache.org/docs/apache-airflow/stable/_api/airflow/models/baseoperator/index.html#airflow.models.baseoperator.BaseOperator)

image

After

image


^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.

@boring-cyborg boring-cyborg bot added area:API Airflow's REST/HTTP API area:core-operators Operators, Sensors and hooks within Core Airflow provider:cncf-kubernetes Kubernetes provider related issues area:lineage area:Scheduler including HA (high availability) scheduler labels Jan 19, 2022
@ashb ashb added kind:documentation and removed area:Scheduler including HA (high availability) scheduler area:API Airflow's REST/HTTP API provider:cncf-kubernetes Kubernetes provider related issues area:lineage area:core-operators Operators, Sensors and hooks within Core Airflow labels Jan 19, 2022
@potiuk
Copy link
Member

potiuk commented Jan 19, 2022

HELL YEAH!

BTW. I guess the main reason you did it is to finally reach negative net number of lines changed in Airflow ?

@ashb
Copy link
Member Author

ashb commented Jan 19, 2022

I mean that was certainly part of the reason. A big part.

It just happens to help that it's also the right thing to do 😁

@github-actions
Copy link

The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Jan 19, 2022
@ashb
Copy link
Member Author

ashb commented Jan 20, 2022

Looks like some spelling errors (aka ClassNames) coming in via the types now need to be added to dictionary

@potiuk
Copy link
Member

potiuk commented Jan 20, 2022

Looks like some spelling errors (aka ClassNames) coming in via the types now need to be added to dictionary

But images are ok, all tests pass and all looks good besides :)

@ashb
Copy link
Member Author

ashb commented Jan 20, 2022

Right, I think I've got all the type-induced spelling errors, unless one crept back in when rebasing 🤞🏻

@potiuk
Copy link
Member

potiuk commented Jan 20, 2022

2 errors left @ashb !

@potiuk
Copy link
Member

potiuk commented Jan 20, 2022

And conflicts with my cloud formation change :(

@ashb
Copy link
Member Author

ashb commented Jan 20, 2022

And conflicts with my cloud formation change :(

Fixed the errors.

Has your change merged? Ah, yes, conflicts already I see

ashb added 2 commits January 20, 2022 20:25
Since we have no updated sphinx-autoapi to a more recent version it
supports showing type hints in the documentation, so we don't need to
have the type hints _and_ the `:type` lines -- which is good, as the
ones in the doc strings are easy to get out of date!

The following settings have been set:

`autodoc_typehints = 'description'` -- show types in description (where
previous `:type` used to show up)

`autodoc_typehints_description_target = 'documented'` -- only link to
types that are documented. (Without this we have some missing return
types that aren't documented, and aren't linked to in our current python
API docs, so this caused a build failure)

`autodoc_typehints_format = 'short'` -- Shorten type hints where
possible, i.e. `StringIO` instead of `io.StringIO`
Now that we are using the type hints in the docs, sphinxcontrib-spelling
picks them up as words to be checked, so we have to ignore them.

I've chosen to add the provider specific ones to local dictionary files
rather than the global, as for example, `mgmt` is an error in most
places, but not in some of the Azure provider.
@ashb ashb force-pushed the doc-types-from-hints branch from 4685698 to b3aec74 Compare January 20, 2022 20:25
@ashb
Copy link
Member Author

ashb commented Jan 20, 2022

@potiuk Any idea what failed with the 'Constraints" job https://github.com/apache/airflow/runs/4888325400?check_suite_focus=true I don't actually see any error -- just some process exited with 1.

(I thought we only ran that on main, not on PRs?)

Ah, it's just the Push that only runs on main. That makes sense.

@ashb
Copy link
Member Author

ashb commented Jan 20, 2022

Oh there's the error much futher up https://github.com/apache/airflow/runs/4888325400?check_suite_focus=true#step:7:580

#29 8.356 The conflict is caused by:
#29 8.356     apache-airflow[devel-ci] 2.3.0.dev0 depends on sphinx<5.0.0 and >=4.4.0
#29 8.356     The user requested (constraint) sphinx==4.3.2

Ummmm, yeah, something is wrong about constraint generation now, as it's trying to generate new constraints while using the old file?!

@potiuk
Copy link
Member

potiuk commented Jan 20, 2022

Rebase ?

@ashb
Copy link
Member Author

ashb commented Jan 20, 2022

Already up to date.

@potiuk
Copy link
Member

potiuk commented Jan 20, 2022

Hmm. Will take a look in a bit

@potiuk
Copy link
Member

potiuk commented Jan 20, 2022

We can merge the change now. The problem was because of one line missing in the latest refactor:
Fix is here: #21000

@potiuk potiuk merged commit 602abe8 into apache:main Jan 20, 2022
@potiuk
Copy link
Member

potiuk commented Jan 20, 2022

BTW. This time the round number is mine ;)

@ashb
Copy link
Member Author

ashb commented Jan 21, 2022

We can merge the change now. The problem was because of one line missing in the latest refactor: Fix is here: #21000

Thanks, I had a feeling it would be something like this but didn't want to break main if it was a bigger problem.

@ashb ashb deleted the doc-types-from-hints branch January 21, 2022 09:24
@josh-fell josh-fell mentioned this pull request Feb 1, 2022
@josh-fell josh-fell mentioned this pull request Mar 19, 2022
@ephraimbuddy ephraimbuddy added the type:misc/internal Changelog: Misc changes that should appear in change log label Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
full tests needed We need to run full set of tests for this PR to merge kind:documentation type:misc/internal Changelog: Misc changes that should appear in change log
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants