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

fix!: stubs breaking mypy #319

Merged
merged 5 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ FUNCTION (PY_ADD_PACKAGE_DIRECTORY NAME)
COMMAND cp "${CMAKE_SOURCE_DIR}/lib/${LIBRARY_TARGET}.*${EXTENSION}*.so" "${CMAKE_CURRENT_BINARY_DIR}/${NAME}/${PROJECT_PATH}/"
COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/requirements.txt" "${CMAKE_CURRENT_BINARY_DIR}/${NAME}/requirements.txt"
COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/README.md" "${CMAKE_CURRENT_BINARY_DIR}/${NAME}/README.md"
COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/py.typed" "${CMAKE_CURRENT_BINARY_DIR}/${NAME}/${PROJECT_PATH}/py.typed"
COMMAND cd "${CMAKE_CURRENT_BINARY_DIR}/${NAME}" && python${PYTHON_VERSION} -m pip install .
COMMAND python${PYTHON_VERSION} -m "pybind11_stubgen" -o "${CMAKE_CURRENT_BINARY_DIR}/${NAME}" "${PROJECT_GROUP}.${PROJECT_SUBGROUP}" # generate stubs in same dir as binaries
COMMAND find "${CMAKE_CURRENT_BINARY_DIR}/${NAME}/${PROJECT_GROUP}" -type f -name "*.pyi" -exec sed -i "s/: \\\\.\\\\.\\\\./: typing.Any/g" {} + # crudely fix stubs with invalid syntax
COMMAND cd "${CMAKE_CURRENT_BINARY_DIR}/${NAME}" && python${PYTHON_VERSION} -m build --no-isolation -w
COMMAND mkdir -p "${CMAKE_CURRENT_BINARY_DIR}/dist"
COMMAND cp "${CMAKE_CURRENT_BINARY_DIR}/${NAME}/dist/*" "${CMAKE_CURRENT_BINARY_DIR}/dist"
Expand Down
Empty file removed bindings/python/py.typed
Empty file.
2 changes: 1 addition & 1 deletion bindings/python/src/OpenSpaceToolkitPhysicsPy/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ inline void OpenSpaceToolkitPhysicsPy_Unit(pybind11::module& aModule)
)doc"
)
.value(
"None",
"None_",
Unit::Type::None,
R"doc(
None unit type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@

from ostk.core.filesystem import Path
from ostk.core.filesystem import File

import ostk.physics as physics

BulletinA = physics.coordinate.frame.provider.iers.BulletinA
Finals2000A = physics.coordinate.frame.provider.iers.Finals2000A
from ostk.physics.coordinate.frame.provider.iers import BulletinA
from ostk.physics.coordinate.frame.provider.iers import Finals2000A


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

from ostk.physics.time import Scale
from ostk.physics.time import Instant

import ostk.physics as physics

BulletinA = physics.coordinate.frame.provider.iers.BulletinA
from ostk.physics.coordinate.frame.provider.iers import BulletinA


class TestBulletinA:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

from ostk.physics.time import Scale
from ostk.physics.time import Instant

import ostk.physics as physics

Finals2000A = physics.coordinate.frame.provider.iers.Finals2000A
from ostk.physics.coordinate.frame.provider.iers import Finals2000A


class TestFinals2000A:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

from ostk.physics.time import Scale
from ostk.physics.time import Instant

from ostk.physics.environment.atmospheric.earth import CSSISpaceWeather


Expand Down Expand Up @@ -38,7 +37,7 @@ def test_access_observation_interval_success(
)

def test_access_observation_at_success(self, cssi_space_weather: CSSISpaceWeather):
observation: Observation = cssi_space_weather.access_observation_at(
observation: CSSISpaceWeather.Reading = cssi_space_weather.access_observation_at(
Instant.date_time(datetime(2023, 6, 19, 0, 0, 0), Scale.UTC)
)

Expand All @@ -58,8 +57,10 @@ def test_access_daily_prediction_interval_success(
def test_access_daily_prediction_at_success(
self, cssi_space_weather: CSSISpaceWeather
):
prediction: Reading = cssi_space_weather.access_daily_prediction_at(
Instant.date_time(datetime(2023, 8, 3, 0, 0, 0), Scale.UTC)
prediction: CSSISpaceWeather.Reading = (
cssi_space_weather.access_daily_prediction_at(
Instant.date_time(datetime(2023, 8, 3, 0, 0, 0), Scale.UTC)
)
)

assert prediction.date.to_string() == "2023-08-03"
Expand All @@ -78,16 +79,18 @@ def test_access_monthly_prediction_interval_success(
def test_access_monthly_prediction_at_success(
self, cssi_space_weather: CSSISpaceWeather
):
prediction: Reading = cssi_space_weather.access_monthly_prediction_at(
Instant.date_time(datetime(2029, 1, 1, 0, 0, 0), Scale.UTC)
prediction: CSSISpaceWeather.Reading = (
cssi_space_weather.access_monthly_prediction_at(
Instant.date_time(datetime(2029, 1, 1, 0, 0, 0), Scale.UTC)
)
)

assert prediction.date.to_string() == "2029-01-01"
assert prediction.f107_obs == pytest.approx(83.5)
assert prediction.f107_obs_center_81 == pytest.approx(83.6)

def test_access_reading_at_success(self, cssi_space_weather: CSSISpaceWeather):
reading: Reading = cssi_space_weather.access_reading_at(
reading: CSSISpaceWeather.Reading = cssi_space_weather.access_reading_at(
Instant.date_time(datetime(2029, 1, 1, 0, 0, 0), Scale.UTC)
)

Expand All @@ -99,7 +102,7 @@ def test_access_reading_at_success(self, cssi_space_weather: CSSISpaceWeather):
def test_access_last_reading_where_success(
self, cssi_space_weather: CSSISpaceWeather
):
reading: Reading = cssi_space_weather.access_last_reading_where(
reading: CSSISpaceWeather.Reading = cssi_space_weather.access_last_reading_where(
lambda reading: reading.f107_data_type == "PRD",
Instant.date_time(datetime(2023, 12, 1, 0, 0, 0), Scale.UTC),
)
Expand Down