Skip to content

Commit

Permalink
Version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludex committed Oct 3, 2022
1 parent 84e2ab5 commit c7d5364
Show file tree
Hide file tree
Showing 14 changed files with 126 additions and 534 deletions.
54 changes: 54 additions & 0 deletions docs/deprecation.md
@@ -0,0 +1,54 @@
# Deprecation Policy

The goal of this policy is to reduce the impact of changes on users and developers of the project by providing
clear guidelines and a well-defined process for deprecating functionalities. This policy applies to both features
and API interfaces.

## Starlette Versions

Starlette follows [Semantic Versioning](https://semver.org/), with some additional constraints.

## Deprecation Types

We'll consider two kinds of deprecations: **Python version** and **feature** deprecations.

### Python Version Deprecation

Starlette will aim to support a Python version until the [EOL date of that version](https://endoflife.date/python).
When a Python version reaches EOL, Starlette will drop support for that version in the next **minor** release.

The drop of Python version support will be documented in the release notes, but the user will **not** be warned it.

### Feature Deprecation

Starlette will deprecate a feature in the next **minor** release after the feature is marked as deprecated.

The deprecation of a feature needs to be followed by a warning message using `warnings.warn` in the code that
uses the deprecated feature. The warning message should include the version in which the feature will be removed.

The format of the message should follow:

> *`code` is deprecated and will be removed in version `version`.*
The `code` can be a *function*, *module* or *feature* name, and the `version` should be the next major release.

The deprecation warning may include an advice on how to replace the deprecated feature.

> *Use `alternative` instead.*
As a full example, imagine we are in version 1.0.0, and we want to deprecate the `potato` function.
We would add the follow warning:

```python
def potato():
warnings.warn(
"potato is deprecated and will be removed in version 2.0.0. "
"Use banana instead.",
DeprecationWarning,
)

def banana():
...
```

The deprecation of a feature will be documented in the release notes, and the user will be warned about it.
28 changes: 28 additions & 0 deletions docs/release-notes.md
@@ -1,3 +1,31 @@
## 1.0.0

Wow!!! 1.0.0 is here! 🎉

### Removed

* Removed `WSGIMiddleware`, which is deprecated since `0.19.0`. Please use [`a2wsgi`](https://github.com/abersheeran/a2wsgi) instead.
* Removed `run_until_first_complete`, which is deprecated since `0.19.0`.
* Removed `iscoroutinefunction_or_partial`, which is deprecated since `0.20.1`.
It was an internal function, which we have replaced by `_utils.is_async_callable`.
* Removed `WS_1004_NO_STATUS_RCVD` and `WS_1005_ABNORMAL_CLOSURE` from the `status` module, which were deprecated since `0.19.1`.
* Removed `ExceptionMiddleware` from the `exceptions` module, which was deprecated since `0.19.1`.
The same middleware can be found in the `middleware.exceptions` module.

### Deprecated

* Deprecated `BaseHTTPMiddleware`. Please refer to [Pure ASGI Middleware](https://www.starlette.io/middleware/#pure-asgi-middleware)
for recommended approach.
* Deprecated `Router.on_event` decorator. Please refer to [Registering events](https://www.starlette.io/events/#registering-events)
for recommended approach.
* Deprecated `Router.websocket_route` decorator. Please refer to [WebSocket Routing](https://www.starlette.io/routing/#websocket-routing)
for recommended approach.
* Deprecated `Router.route` decorator. Please refer to [HTTP Routing](https://www.starlette.io/routing/#http-routing) for recommended approach.
* Deprecated `Router.host` method. Please refer to [Host-based routing](https://www.starlette.io/routing/#host-based-routing)
for recommended approach.
* Deprecated `Router.mount` method. Please refer to [Submounting routes](https://www.starlette.io/routing/#submounting-routes)
for recommended approach.

## 0.21.0

September 26, 2022
Expand Down
3 changes: 2 additions & 1 deletion mkdocs.yml
Expand Up @@ -45,6 +45,7 @@ nav:
- Test Client: 'testclient.md'
- Third Party Packages: 'third-party-packages.md'
- Contributing: 'contributing.md'
- Deprecation Policy: 'deprecation.md'
- Release Notes: 'release-notes.md'

markdown_extensions:
Expand All @@ -53,7 +54,7 @@ markdown_extensions:
- pymdownx.highlight
- pymdownx.superfences
- pymdownx.tabbed:
alternate_style: true
alternate_style: true

extra_javascript:
- 'js/chat.js'
Expand Down
2 changes: 0 additions & 2 deletions setup.cfg
Expand Up @@ -28,8 +28,6 @@ xfail_strict=True
filterwarnings=
# Turn warnings that aren't filtered into exceptions
error
ignore: run_until_first_complete is deprecated and will be removed in a future version.:DeprecationWarning
ignore: starlette\.middleware\.wsgi is deprecated and will be removed in a future release\.*:DeprecationWarning
ignore: Async generator 'starlette\.requests\.Request\.stream' was garbage collected before it had been exhausted.*:ResourceWarning
ignore: path is deprecated.*:DeprecationWarning:certifi
ignore: Use 'content=<...>' to upload raw bytes/text content.:DeprecationWarning
Expand Down
2 changes: 1 addition & 1 deletion starlette/__init__.py
@@ -1 +1 @@
__version__ = "0.21.0"
__version__ = "1.0.0"
18 changes: 0 additions & 18 deletions starlette/concurrency.py
@@ -1,7 +1,6 @@
import functools
import sys
import typing
import warnings

import anyio

Expand All @@ -15,23 +14,6 @@
P = ParamSpec("P")


async def run_until_first_complete(*args: typing.Tuple[typing.Callable, dict]) -> None:
warnings.warn(
"run_until_first_complete is deprecated "
"and will be removed in a future version.",
DeprecationWarning,
)

async with anyio.create_task_group() as task_group:

async def run(func: typing.Callable[[], typing.Coroutine]) -> None:
await func()
task_group.cancel_scope.cancel()

for func, kwargs in args:
task_group.start_soon(run, functools.partial(func, **kwargs))


async def run_in_threadpool(
func: typing.Callable[P, T], *args: P.args, **kwargs: P.kwargs
) -> T:
Expand Down
24 changes: 0 additions & 24 deletions starlette/exceptions.py
@@ -1,8 +1,5 @@
import http
import typing
import warnings

__all__ = ("HTTPException", "WebSocketException")


class HTTPException(Exception):
Expand Down Expand Up @@ -31,24 +28,3 @@ def __init__(self, code: int, reason: typing.Optional[str] = None) -> None:
def __repr__(self) -> str:
class_name = self.__class__.__name__
return f"{class_name}(code={self.code!r}, reason={self.reason!r})"


__deprecated__ = "ExceptionMiddleware"


def __getattr__(name: str) -> typing.Any: # pragma: no cover
if name == __deprecated__:
from starlette.middleware.exceptions import ExceptionMiddleware

warnings.warn(
f"{__deprecated__} is deprecated on `starlette.exceptions`. "
f"Import it from `starlette.middleware.exceptions` instead.",
category=DeprecationWarning,
stacklevel=3,
)
return ExceptionMiddleware
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")


def __dir__() -> typing.List[str]:
return sorted(list(__all__) + [__deprecated__]) # pragma: no cover
9 changes: 9 additions & 0 deletions starlette/middleware/base.py
@@ -1,4 +1,5 @@
import typing
import warnings

import anyio

Expand All @@ -12,6 +13,14 @@
]
T = typing.TypeVar("T")

warnings.warn(
"The 'BaseHTTPMiddleware' is deprecated, and will be removed in version 2.0.0."
"Refer to https://www.starlette.io/middleware/#pure-asgi-middleware to learn "
"how to create middlewares.\nIf you need help, please create a discussion on: "
"https://github.com/encode/starlette/discussions.",
DeprecationWarning,
)


class BaseHTTPMiddleware:
def __init__(
Expand Down
140 changes: 0 additions & 140 deletions starlette/middleware/wsgi.py

This file was deleted.

0 comments on commit c7d5364

Please sign in to comment.