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

Add ad-rss Type-Stubs #8111

Open
wants to merge 10 commits into
base: ue4-dev
Choose a base branch
from

Conversation

Daraan
Copy link

@Daraan Daraan commented Sep 4, 2024

Description

This PR is the continuation of #7787 and #8564 that added type hints for the carla package.

This PR contains:

  • added stubs for carla.Rss* classes
  • added weak carla.ad type hints; also they are only included in the rss build. This needs modification of the setup and some cleaning. If you prefer they could be included in all builds.
  • Solve setup.py not to include rss files into non-rss build (happens when rebuilding without cleaning build dir).
    If someone has a better idea how to prevent copying of the source/carla/ad/ if one does a normal build after an rss build please feel to share your ideas. I am not sure how far we can go with MANIFEST.in files. Or doing a more thorough cleanup before.
    Currently these files will be removed instead of keeping them around, as otherwise past with-rss-build artifacts are not removed and packed.

Important

The type stubs for the ad library are only minimally done there are many things missing (top-level functions & attributes), wrong (e.g. overloads) or incomplete. I will not continue the work on the ad subpackage.
On my repo I have a tag with alternative type stubs for ad that can be used to complement the ones in this PR. Those are more complete but lack function signatures and types: https://github.com/Daraan/LunaticAI-Driver-for-CARLA-Simulator/releases/tag/deleted-Alternative-ad-type-stubs

How can you contribute:

Carla package
  • testing of the carla type hints and extending where necessary. Property setters and in-place setters are likely missing.
    You can use ruff and
     ruff check PythonAPI/carla/source/carla --select ANN --ignore ANN101,ANN102
    Use --exclude *ad/rss,*ad/map to exclude the SyntaxError from these two files while they are not addressed or the whole ad subpackage.
ad subpackage
  • Finishing type stubs for the ad subpackage.
    • add missing global attributes and functions
    • cleaning
    • overloads and property signatures

Note

With #8152 it became easier for stub creation tools like mypy to create minimal stubs automatically


Further contributions

Feel free to make PRs against my fork https://github.com/Daraan/CARLA-Simulator-Fork-DebianFix/tree/type-hinting-to-dev to the type-hinting-to-dev branch.

Where has this been tested?

  • Platform(s): Ubuntu 22.04
  • Python version(s):
    • 2.7 RSS build fails, without OK
    • 3.10with and without RSS

Possible Drawbacks


This change is Reviewable

Copy link

update-docs bot commented Sep 4, 2024

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would update our CHANGELOG.md based on your changes.

@Daraan Daraan force-pushed the type-hinting-to-dev branch 2 times, most recently from 1f0ca19 to b7df53f Compare September 6, 2024 17:29
@Daraan Daraan force-pushed the type-hinting-to-dev branch 2 times, most recently from 77bb709 to 640c076 Compare September 18, 2024 12:56
@Daraan Daraan force-pushed the type-hinting-to-dev branch from 640c076 to 315c318 Compare October 7, 2024 08:04
@Daraan Daraan force-pushed the type-hinting-to-dev branch from 315c318 to 4d83a99 Compare October 14, 2024 13:30
@Daraan Daraan force-pushed the type-hinting-to-dev branch from 4d83a99 to 50b85ae Compare January 25, 2025 11:38
@Daraan Daraan changed the base branch from dev to ue4-dev January 25, 2025 11:38
@Daraan Daraan changed the title [Help wanted] Improvement of Python Type Stubs - Update availaible Add ad-rss Type-Stubs Jan 25, 2025
@Daraan Daraan marked this pull request as ready for review January 25, 2025 11:54
@Daraan Daraan requested a review from a team as a code owner January 25, 2025 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant