Skip to content

Commit

Permalink
chore: remove optional dependencies, fix typos (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lancetnik authored Feb 25, 2024
1 parent 90d4f87 commit cebf0b0
Show file tree
Hide file tree
Showing 18 changed files with 49 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ jobs:
with:
key: ${{ github.ref }}
path: .cache
- run: pip install -e ".[doc]"
- run: pip install -r requirements.docs.txt
- working-directory: ./docs
run: mkdocs gh-deploy --force
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-test-v03
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pip install -e .[test]
run: pip install -r requirements.test.txt
- name: Install Pydantic v1
if: matrix.pydantic-version == 'pydantic-v1'
run: pip install "pydantic>=1.10.0,<2.0.0"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ __pycache__
.vscode
.pypirc
venv
.venv
app
serve.py
test.py
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ python -m pip install --upgrade pip
After activating the environment as described above:

```bash
pip install -e ."[dev]"
pip install -r requirements.dev.txt
```

It will install all the dependencies and your local FastDepends in your local environment.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ This is a small library which provides you with the ability to use lovely FastAP
projects or tools.

Thanks to [*fastapi*](https://fastapi.tiangolo.com/) and [*pydantic*](https://docs.pydantic.dev/) projects for this
greate functionality. This package is just a small change of the original FastAPI sources to provide DI functionality in a pure-Python way.
great functionality. This package is just a small change of the original FastAPI sources to provide DI functionality in a pure-Python way.

Async and sync modes are both supported.

# For why?

This project should be extreamly helpfull to boost your not-**FastAPI** applications (even **Flask**, I know that u like some legacy).
This project should be extremely helpful to boost your not-**FastAPI** applications (even **Flask**, I know that u like some legacy).

Also the project can be a core of your own framework for anything. Actually, it was build for my another project - :rocket:[**Propan**](https://github.com/Lancetnik/Propan):rocket: (and [**FastStream**](https://github.com/airtai/faststream)), check it to see full-featured **FastDepends** usage example.

Expand Down
4 changes: 2 additions & 2 deletions docs/docs/advanced/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# CustomField

!!! warning "Packages developers"
This is the part of documentation will talks you about some features, that can be helpfull to develop your own packages with `FastDepends`
This is the part of documentation will talks you about some features, that can be helpful to develop your own packages with `FastDepends`

## Custom Arguments Field

Expand Down Expand Up @@ -65,7 +65,7 @@ class CustomField:

!!! note
Pydantic understands only python-native annotation or Pydantic classes. If users will annotate your fields by other classes,
you should set `cast=False` to avoid pydantic exeptions.
you should set `cast=False` to avoid pydantic exceptions.

```python
def use(self, **kwargs: AnyDict) -> AnyDict: ...
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/alternatives.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

`FastDepend` is a very small toolkit to achieve one point: provide you with opportunity to use **FastAPI** `Depends` and typecasting everywhere.

Sometimes, more complex tools are required. In these cases I can reccomend you to take a look at the following projects
Sometimes, more complex tools are required. In these cases I can recommend you to take a look at the following projects

## [DI](https://adriangb.com/di/)

Expand All @@ -14,7 +14,7 @@ Key features:
* Auto-wiring: `di` also supports auto-wiring using type annotations
* Scopes: inspired by `pytest scopes`, but defined by users
* Composable: decoupled internal APIs give you the flixibility to customize wiring, execution and binding.
* Performant: `di` can execute dependencies in parallel and cache results ins scopes.
* Performance: `di` can execute dependencies in parallel and cache results ins scopes.

## [Dependency Injector](https://python-dependency-injector.etc-labs.org)

Expand All @@ -32,5 +32,5 @@ Key features:
* Wiring
* Asynchronous
* Typing
* Perfomance
* Performance
* Maturity
2 changes: 1 addition & 1 deletion docs/docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ python -m pip install --upgrade pip
After activating the environment as described above:

```bash
pip install -e ."[dev]"
pip install -r requirements.dev.txt
```

It will install all the dependencies and your local FastDepends in your local environment.
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ This is a small library which provides you with the ability to use lovely FastAP
projects or tools.

Thanks to [*fastapi*](https://fastapi.tiangolo.com/) and [*pydantic*](https://docs.pydantic.dev/) projects for this
greate functionality. This package is just a small change of the original FastAPI sources to provide DI functionality in a pure-Python way.
great functionality. This package is just a small change of the original FastAPI sources to provide DI functionality in a pure-Python way.

Async and sync modes are both supported.

# For why?

This project should be extreamly helpfull to boost your not-**FastAPI** applications (even **Flask**, I know that u like some legacy).
This project should be extremely helpful to boost your not-**FastAPI** applications (even **Flask**, I know that u like some legacy).

Also the project can be a core of your own framework for anything. Actually, it was build for my another project - :rocket:[**Propan**](https://github.com/Lancetnik/Propan):rocket: (and [**FastStream**](https://github.com/airtai/faststream)), check it to see full-featured **FastDepends** usage example.

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/tutorial/classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ will be the type of your dependency:
### CALL (2-nd call)

If you wish to specify your dependency behavior earlier, you can use `__call__` method of
already inititalized class object.
already initialized class object.

```python linenums="1" hl_lines="7-8 11"
{!> docs_src/tutorial_2_classes/tutorial_3.py !}
Expand Down
15 changes: 7 additions & 8 deletions docs/docs/tutorial/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ I suppose, if you are already here, you are exactly known about this library usa

It is using the same way as [FastAPI](https://fastapi.tiangolo.com/tutorial/dependencies/) is.

But, I can remember you, if it's nessesary.
But, I can remember you, if it's necessary.

## Basic usage

Expand Down Expand Up @@ -62,7 +62,7 @@ That was easy, isn't it?

## Nested Dependencies

Dependecies are also able to contain their own dependencies. There is nothing unexpected with this case:
Dependencies are also able to contain their own dependencies. There is nothing unexpected with this case:
just declare `Depends` requirement at original dependency function.

=== "Sync"
Expand All @@ -81,19 +81,18 @@ just declare `Depends` requirement at original dependency function.

!!! Tip "Cache"
At the examples above `another_dependency` was called **AT ONCE!**.
`FastDepends` caches all dependecies responses throw **ONE** `@inject` callstask.
`FastDepends` caches all dependencies responses throw **ONE** `@inject` callstask.
It means, that all nested dependencies give a one-time cached response. But,
with different injected function calls, cache will differ too.

To disable that behavior, just use `Depends(..., cache=False)`. This way dependency will
be executed each time.


## Dependencies type casting

If you remember, `FastDepends` casts function `return` too. This means, dependecy output
will be casted twice: at dependecy function *out* and at the injector *in*. Nothing bad,
if they are the same type, nothing overhead occures. Just keep it in your mind. Or don't...
If you remember, `FastDepends` casts function `return` too. This means, dependency output
will be casted twice: at dependency function *out* and at the injector *in*. Nothing bad,
if they are the same type, nothing overhead occurs. Just keep it in your mind. Or don't...
My work is done anyway.

```python linenums="1"
Expand All @@ -110,7 +109,7 @@ def method(a: int, d: int = Depends(simple_dependency)):
assert method("1") == 5
```

Also, `return` type will be cached. If you are using this dependcy at `N` functions,
Also, `return` type will be cached. If you are using this dependency at `N` functions,
cached return will be casted `N` times.

To avoid this problem use [mypy](https://www.mypy-lang.org) to check types at your project or
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/tutorial/yield.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generators

Sometimes we want to call something *before* and *after* original funtion call.
Sometimes we want to call something *before* and *after* original function call.

That purpouse can be reached by using `yield` keyword.

Expand Down Expand Up @@ -28,7 +28,7 @@ The code following the `yield` statement is executed after the original function
and only `sync` declaration with a `sync` one.

!!! warning
All errors occures at original function or another dependencies will be raised this place
All errors occurs at original function or another dependencies will be raised this place
```python linenums="1" hl_lines="3"
{!> docs_src/tutorial_3_yield/tutorial_1.py !}
```
Expand Down
2 changes: 1 addition & 1 deletion fast_depends/__about__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""FastDepends - extracted and cleared from HTTP domain FastAPI Dependency Injection System"""

__version__ = "2.4.0"
__version__ = "2.4.1"
27 changes: 4 additions & 23 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,6 @@ dependencies = [
"anyio>=3.0.0,<5.0.0",
]

[project.optional-dependencies]
test = [
"coverage[toml]>=7.2.0,<8.0.0",
"pytest>=8.0.0,<9",
"dirty-equals>=0.7.0,<0.8",
]

doc = [
"mkdocs-material >=9.4.0,<10.0.0",
"mkdocs-minify-plugin >=0.7.0,<1.0.0",
"mdx-include >=1.4.1,<2.0.0",
"mkdocs-markdownextradata-plugin >=0.1.7,<0.3.0",
]

dev = [
"fast-depends[test]",
"fast-depends[doc]",

"mypy>=1.8.0",
"ruff==0.2.2",
]

[project.urls]
Homepage = "https://lancetnik.github.io/FastDepends/"
Documentation = "https://lancetnik.github.io/FastDepends/"
Expand Down Expand Up @@ -165,4 +143,7 @@ omit = [
'*/__about__.py',
'*/__main__.py',
'*/__init__.py',
]
]

[tool.codespell]
skip = "venv,./docs/site/*,*.js,*.css"
8 changes: 8 additions & 0 deletions requirements.dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-e .

-r requirements.docs.txt
-r requirements.test.txt

mypy >=1.8.0
ruff ==0.2.2
codespell ==2.2.6
4 changes: 4 additions & 0 deletions requirements.docs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mkdocs-material >=9.4.0,<10.0.0
mkdocs-minify-plugin >=0.7.0,<1.0.0
mdx-include >=1.4.1,<2.0.0
mkdocs-markdownextradata-plugin >=0.1.7,<0.3.0
5 changes: 5 additions & 0 deletions requirements.test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-e .

coverage[toml] >=7.2.0,<8.0.0
pytest >=8.0.0,<9
dirty-equals >=0.7.0,<0.8
3 changes: 3 additions & 0 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ ruff fast_depends tests --fix

echo "Running ruff formatter (black replacement)..."
ruff format tests

echo "Running codespell to find typos..."
codespell

0 comments on commit cebf0b0

Please sign in to comment.