Skip to content

Commit 8649162

Browse files
authored
Add stubs for ephem (#15191)
1 parent 127e4d2 commit 8649162

File tree

7 files changed

+700
-0
lines changed

7 files changed

+700
-0
lines changed

pyrightconfig.stricter.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"stubs/defusedxml",
3535
"stubs/docker",
3636
"stubs/docutils",
37+
"stubs/ephem",
3738
"stubs/Flask-SocketIO",
3839
"stubs/fpdf2",
3940
"stubs/gdb",
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Tests
2+
ephem.tests.*
3+
4+
# Leaked loop variables
5+
ephem.stars.k
6+
ephem.stars.v
7+
8+
# Runtime signature has *args/**kwargs that raise TypeError; stub signature is correct
9+
ephem._libastro.Observer.__init__
10+
ephem.FixedBody.__init__
11+
ephem._libastro.FixedBody.__init__

stubs/ephem/METADATA.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
version = "4.2.*"
2+
upstream_repository = "https://github.com/brandon-rhodes/pyephem"

stubs/ephem/ephem/__init__.pyi

Lines changed: 287 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,287 @@
1+
from collections.abc import Callable
2+
from datetime import datetime as _datetime, timedelta as _timedelta, tzinfo as _tzinfo
3+
from typing import Final, NoReturn, overload
4+
from typing_extensions import Self
5+
6+
from . import _libastro
7+
8+
__version__: Final[str]
9+
10+
# Mathematical constants
11+
tau: Final[float]
12+
twopi: Final[float]
13+
halfpi: Final[float]
14+
quarterpi: Final[float]
15+
eighthpi: Final[float]
16+
degree: Final[float]
17+
arcminute: Final[float]
18+
arcsecond: Final[float]
19+
half_arcsecond: Final[float]
20+
tiny: Final[float]
21+
22+
# Physical constants
23+
c: Final[float]
24+
meters_per_au: Final[float]
25+
earth_radius: Final[float]
26+
moon_radius: Final[float]
27+
sun_radius: Final[float]
28+
29+
# Epoch constants
30+
B1900: Final[float]
31+
B1950: Final[float]
32+
J2000: Final[float]
33+
34+
# Type imports from _libastro
35+
Angle = _libastro.Angle
36+
degrees = _libastro.degrees
37+
hours = _libastro.hours
38+
Date = _libastro.Date
39+
40+
# Time constants
41+
hour: Final[float]
42+
minute: Final[float]
43+
second: Final[float]
44+
45+
# Precision constants
46+
default_newton_precision: Final[float]
47+
rise_set_iterations: Final[tuple[int, int, int, int, int, int, int]]
48+
49+
# Function imports from _libastro
50+
delta_t = _libastro.delta_t
51+
julian_date = _libastro.julian_date
52+
53+
# Body type imports from _libastro
54+
Body = _libastro.Body
55+
Planet = _libastro.Planet
56+
PlanetMoon = _libastro.PlanetMoon
57+
FixedBody = _libastro.FixedBody
58+
EllipticalBody = _libastro.EllipticalBody
59+
ParabolicBody = _libastro.ParabolicBody
60+
HyperbolicBody = _libastro.HyperbolicBody
61+
EarthSatellite = _libastro.EarthSatellite
62+
63+
# Database and coordinate functions from _libastro
64+
readdb = _libastro.readdb
65+
readtle = _libastro.readtle
66+
constellation = _libastro.constellation
67+
separation = _libastro.separation
68+
unrefract = _libastro.unrefract
69+
now = _libastro.now
70+
71+
# Star atlas functions from _libastro
72+
millennium_atlas = _libastro.millennium_atlas
73+
uranometria = _libastro.uranometria
74+
uranometria2000 = _libastro.uranometria2000
75+
76+
# Special planet classes from _libastro
77+
Jupiter = _libastro.Jupiter
78+
Saturn = _libastro.Saturn
79+
Moon = _libastro.Moon
80+
81+
# Dynamically created planet classes
82+
class Mercury(Planet):
83+
__planet__: Final = 0
84+
85+
class Venus(Planet):
86+
__planet__: Final = 1
87+
88+
class Mars(Planet):
89+
__planet__: Final = 2
90+
91+
class Uranus(Planet):
92+
__planet__: Final = 5
93+
94+
class Neptune(Planet):
95+
__planet__: Final = 6
96+
97+
class Pluto(Planet):
98+
__planet__: Final = 7
99+
100+
class Sun(Planet):
101+
__planet__: Final = 8
102+
103+
# Planet moon classes
104+
class Phobos(PlanetMoon):
105+
__planet__: Final = 10
106+
107+
class Deimos(PlanetMoon):
108+
__planet__: Final = 11
109+
110+
class Io(PlanetMoon):
111+
__planet__: Final = 12
112+
113+
class Europa(PlanetMoon):
114+
__planet__: Final = 13
115+
116+
class Ganymede(PlanetMoon):
117+
__planet__: Final = 14
118+
119+
class Callisto(PlanetMoon):
120+
__planet__: Final = 15
121+
122+
class Mimas(PlanetMoon):
123+
__planet__: Final = 16
124+
125+
class Enceladus(PlanetMoon):
126+
__planet__: Final = 17
127+
128+
class Tethys(PlanetMoon):
129+
__planet__: Final = 18
130+
131+
class Dione(PlanetMoon):
132+
__planet__: Final = 19
133+
134+
class Rhea(PlanetMoon):
135+
__planet__: Final = 20
136+
137+
class Titan(PlanetMoon):
138+
__planet__: Final = 21
139+
140+
class Hyperion(PlanetMoon):
141+
__planet__: Final = 22
142+
143+
class Iapetus(PlanetMoon):
144+
__planet__: Final = 23
145+
146+
class Ariel(PlanetMoon):
147+
__planet__: Final = 24
148+
149+
class Umbriel(PlanetMoon):
150+
__planet__: Final = 25
151+
152+
class Titania(PlanetMoon):
153+
__planet__: Final = 26
154+
155+
class Oberon(PlanetMoon):
156+
__planet__: Final = 27
157+
158+
class Miranda(PlanetMoon):
159+
__planet__: Final = 28
160+
161+
# Newton's method
162+
def newton(f: Callable[[float], float], x0: float, x1: float, precision: float = ...) -> float: ...
163+
164+
# Equinox and solstice functions
165+
def holiday(d0: _libastro._DateInitType, motion: float, offset: float) -> Date: ...
166+
def previous_vernal_equinox(date: _libastro._DateInitType) -> Date: ...
167+
def next_vernal_equinox(date: _libastro._DateInitType) -> Date: ...
168+
def previous_summer_solstice(date: _libastro._DateInitType) -> Date: ...
169+
def next_summer_solstice(date: _libastro._DateInitType) -> Date: ...
170+
def previous_autumnal_equinox(date: _libastro._DateInitType) -> Date: ...
171+
def next_autumnal_equinox(date: _libastro._DateInitType) -> Date: ...
172+
def previous_winter_solstice(date: _libastro._DateInitType) -> Date: ...
173+
def next_winter_solstice(date: _libastro._DateInitType) -> Date: ...
174+
175+
# Synonyms
176+
next_spring_equinox = next_vernal_equinox
177+
previous_spring_equinox = previous_vernal_equinox
178+
next_fall_equinox = next_autumnal_equinox
179+
next_autumn_equinox = next_autumnal_equinox
180+
previous_fall_equinox = previous_autumnal_equinox
181+
previous_autumn_equinox = previous_autumnal_equinox
182+
183+
# More general equinox/solstice functions
184+
def previous_equinox(date: _libastro._DateInitType) -> Date: ...
185+
def next_equinox(date: _libastro._DateInitType) -> Date: ...
186+
def previous_solstice(date: _libastro._DateInitType) -> Date: ...
187+
def next_solstice(date: _libastro._DateInitType) -> Date: ...
188+
def previous_new_moon(date: _libastro._DateInitType) -> Date: ...
189+
def next_new_moon(date: _libastro._DateInitType) -> Date: ...
190+
def previous_first_quarter_moon(date: _libastro._DateInitType) -> Date: ...
191+
def next_first_quarter_moon(date: _libastro._DateInitType) -> Date: ...
192+
def previous_full_moon(date: _libastro._DateInitType) -> Date: ...
193+
def next_full_moon(date: _libastro._DateInitType) -> Date: ...
194+
def previous_last_quarter_moon(date: _libastro._DateInitType) -> Date: ...
195+
def next_last_quarter_moon(date: _libastro._DateInitType) -> Date: ...
196+
197+
# Exceptions
198+
class CircumpolarError(ValueError): ...
199+
class NeverUpError(CircumpolarError): ...
200+
class AlwaysUpError(CircumpolarError): ...
201+
202+
# Observer class
203+
class Observer(_libastro.Observer):
204+
__slots__: list[str] = ["name"]
205+
206+
name: object
207+
208+
def copy(self) -> Self: ...
209+
__copy__ = copy
210+
def compute_pressure(self) -> None: ...
211+
def previous_transit(self, body: Body, start: _libastro._DateInitType | None = None) -> Date: ...
212+
def next_transit(self, body: Body, start: _libastro._DateInitType | None = None) -> Date: ...
213+
def previous_antitransit(self, body: Body, start: _libastro._DateInitType | None = None) -> Date: ...
214+
def next_antitransit(self, body: Body, start: _libastro._DateInitType | None = None) -> Date: ...
215+
def disallow_circumpolar(self, declination: float) -> None: ...
216+
def previous_rising(self, body: Body, start: _libastro._DateInitType | None = None, use_center: bool = False) -> Date: ...
217+
def previous_setting(self, body: Body, start: _libastro._DateInitType | None = None, use_center: bool = False) -> Date: ...
218+
def next_rising(self, body: Body, start: _libastro._DateInitType | None = None, use_center: bool = False) -> Date: ...
219+
def next_setting(self, body: Body, start: _libastro._DateInitType | None = None, use_center: bool = False) -> Date: ...
220+
def next_pass(
221+
self, body: EarthSatellite, singlepass: bool = True
222+
) -> tuple[Date | None, Date | None, Date | None, Date | None, Date | None, Date | None]: ...
223+
224+
# Time conversion functions
225+
def localtime(date: Date | float) -> _datetime: ...
226+
227+
class _UTC(_tzinfo):
228+
ZERO: _timedelta
229+
def tzname(self, dt: _datetime | None, /) -> NoReturn: ...
230+
def utcoffset(self, dt: _datetime | None) -> _timedelta: ...
231+
def dst(self, dt: _datetime | None) -> _timedelta: ...
232+
233+
UTC: _UTC
234+
235+
def to_timezone(date: Date | float, tzinfo: _tzinfo) -> _datetime: ...
236+
237+
# Coordinate classes
238+
class Coordinate:
239+
epoch: Date
240+
241+
@overload
242+
def __init__(self, body: Body, *, epoch: _libastro._DateInitType | None = None) -> None: ...
243+
@overload
244+
def __init__(self, coord1: float | str, coord2: float | str, *, epoch: _libastro._DateInitType | None = None) -> None: ...
245+
@overload
246+
def __init__(self, coord: Coordinate, *, epoch: _libastro._DateInitType | None = None) -> None: ...
247+
248+
class Equatorial(Coordinate):
249+
ra: Angle
250+
dec: Angle
251+
252+
def get(self) -> tuple[Angle, Angle]: ...
253+
def set(self, ra: float | str, dec: float | str) -> None: ...
254+
255+
to_radec = get
256+
from_radec = set
257+
258+
class LonLatCoordinate(Coordinate):
259+
lon: Angle
260+
lat: Angle
261+
262+
def set(self, lon: float | str, lat: float | str) -> None: ...
263+
def get(self) -> tuple[Angle, Angle]: ...
264+
@property
265+
def long(self) -> Angle: ...
266+
@long.setter
267+
def long(self, value: Angle) -> None: ...
268+
269+
class Ecliptic(LonLatCoordinate):
270+
def to_radec(self) -> tuple[Angle, Angle]: ...
271+
def from_radec(self, ra: float | str, dec: float | str) -> None: ...
272+
273+
class Galactic(LonLatCoordinate):
274+
def to_radec(self) -> tuple[Angle, Angle]: ...
275+
def from_radec(self, ra: float | str, dec: float | str) -> None: ...
276+
277+
# Backwards compatibility aliases
278+
date = Date
279+
angle = Angle
280+
LongLatCoordinate = LonLatCoordinate
281+
282+
# Catalog functions
283+
@overload
284+
def star(name: str, observer: Observer, /) -> FixedBody: ...
285+
@overload
286+
def star(name: str, when: _libastro._DateInitType, epoch: _libastro._DateInitType) -> FixedBody: ...
287+
def city(name: str) -> Observer: ...

0 commit comments

Comments
 (0)