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

Stop rewriting class names #53

Merged
merged 3 commits into from
Nov 17, 2023
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ You can find our backwards-compatibility policy [here](https://github.com/hynek/
- Flask: `svcs.flask.registry` which is a `werkzeug.local.LocalProxy` for the currently active registry on `flask.current_app`.


### Fixed

- We've stopped rewriting the public names of our objects and `typing.get_type_hints()` now works on them as expected for Python 3.10 and later.
[#52](https://github.com/hynek/issues/pull/52)
[#53](https://github.com/hynek/issues/pull/53)


## [23.20.0](https://github.com/hynek/svcs/compare/23.19.0...23.20.0) - 2023-09-05

### Added
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
exclude_patterns = ["_build"]

nitpick_ignore = [
*[("py:class", f"svcs._core.T{i}") for i in range(1, 11)],
# Welcome, MkDocs projects. :(
("py:class", "FastAPI"),
("py:class", "Starlette"),
Expand Down
9 changes: 0 additions & 9 deletions src/svcs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,3 @@
from . import starlette
except ImportError:
__all__ += ["starlette"]


# Make nicer public names.
__locals = locals()
for __name in __all__:
if not __name.startswith("__") and not __name.islower():
__locals[__name].__module__ = "svcs"
del __locals
del __name # pyright: ignore[reportUnboundVariable]
26 changes: 26 additions & 0 deletions tests/test_typing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# SPDX-FileCopyrightText: 2023 Hynek Schlawack <[email protected]>
#
# SPDX-License-Identifier: MIT

import sys
import typing

import pytest

import svcs


@pytest.mark.skipif(sys.version_info < (3, 10), reason="requires Python 3.10+")
def test_get_type_hints():
"""
typing.get_type_hints() works on our objects on Python 3.10+.

Unfortunately supporting older versions would require to rewrite all type
hints.

Regression test for #52.
"""
typing.get_type_hints(svcs.Registry)
typing.get_type_hints(svcs.Container)
typing.get_type_hints(svcs.ServicePing)
typing.get_type_hints(svcs.RegisteredService)