Skip to content

Add stubs for ephem#15191

Merged
srittau merged 4 commits intopython:mainfrom
Remco646:add-ephem-stubs
Jan 15, 2026
Merged

Add stubs for ephem#15191
srittau merged 4 commits intopython:mainfrom
Remco646:add-ephem-stubs

Conversation

@Remco646
Copy link
Copy Markdown
Contributor

@Remco646 Remco646 commented Dec 29, 2025

This PR adds initial type stubs for the ephem library (PyPI: pyephem).

ephem is a widely used library for high-precision astronomy calculations. Since it is largely implemented in C, static analysis tools currently have difficulty providing completions and type safety for it.

The stubs provide comprehensive coverage for the publicly accessible API, including:

  • The main ephem namespace (__init__)
  • The underlying _libastro C-extension interface
  • The cities and stars databases

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Copy link
Copy Markdown
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

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

Thanks, just a few smaller remarks below.

Comment on lines +1 to +6
ephem.tests.*
ephem.stars.k
ephem.stars.v
ephem._libastro.Observer.__init__
ephem.FixedBody.__init__
ephem._libastro.FixedBody.__init__
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you add comments to group and explain these entries? Probably something like this:

# Tests
ephem.tests.*

# Leaked loop variables
ephem.stars.k
ephem.stars.v

# ?
ephem._libastro.Observer.__init__
ephem.FixedBody.__init__
ephem._libastro.FixedBody.__init__

Comment thread stubs/ephem/ephem/__init__.pyi Outdated

from . import _libastro

__version__: str
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Constants should be marked as Final:

Suggested change
__version__: str
__version__: Final[str]

(Also applies to all the constants below.)

Comment thread stubs/ephem/ephem/stars.pyi Outdated
Comment on lines +14 to +15
STAR_NUMBER_NAME: dict[int, str]
STAR_NAME_NUMBER: dict[str, int]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should probably be Final, too.

@Remco646
Copy link
Copy Markdown
Contributor Author

Thanks for your feedback. All remarks should be resolved now.

@srittau srittau merged commit 8649162 into python:main Jan 15, 2026
48 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

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.

2 participants