Skip to content

Commit

Permalink
Stop rewriting class names (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek authored Nov 17, 2023
1 parent c5c5f48 commit 4b05ab8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
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)

0 comments on commit 4b05ab8

Please sign in to comment.