Skip to content
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
17 changes: 13 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:
JUPYTER_PLATFORM_DIRS: '1'

jobs:
linux:
test:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -20,16 +20,16 @@ jobs:
- python-version: '3.13'
extras: min
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
fetch-depth: 0
filter: blob:none
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: hynek/setup-cached-uv@v2
- uses: astral-sh/setup-uv@v6
with:
cache-dependency-path: pyproject.toml
enable-cache: true
- run: uv pip install --system -e .[${{ matrix.extras == 'min' && 'test' || 'test,jupyter' }}]
- uses: pavelzw/pytest-action@v2
with:
Expand All @@ -38,3 +38,12 @@ jobs:
verbose: true
job-summary: true
emoji: false
check:
if: always()
needs:
- test
runs-on: ubuntu-latest
steps:
- uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
permissions:
id-token: write # to authenticate as Trusted Publisher to pypi.org
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/checkout@v5
- uses: actions/setup-python@v5
with:
python-version: "3.x"
cache: pip
Expand Down
16 changes: 10 additions & 6 deletions src/session_info2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from importlib.metadata import version
from types import MappingProxyType, ModuleType
from typing import TYPE_CHECKING, Any, Literal, TypeAlias
from warnings import catch_warnings, filterwarnings

from . import _pu
from ._dists import packages_distributions
Expand Down Expand Up @@ -118,12 +119,15 @@ def __hash__(self) -> int:
def _version(self, dist: str) -> str:
"""Get version(s) of imported distribution."""
v_meta = version(dist)
vs_attr = {
pkg_name: v
for pkg_name in self.dist2pkgs[dist]
if (pkg := sys.modules.get(pkg_name))
and (v := getattr(pkg, "__version__", None))
}
with catch_warnings():
filterwarnings("ignore", category=DeprecationWarning)
filterwarnings("ignore", category=FutureWarning)
vs_attr = {
pkg_name: v
for pkg_name in self.dist2pkgs[dist]
if (pkg := sys.modules.get(pkg_name))
and (v := getattr(pkg, "__version__", None))
}
if all(v_attr == v_meta for v_attr in vs_attr.values()):
# This branch is also hit if there are no __version__ attributes
return v_meta
Expand Down