Skip to content

Commit

Permalink
add isort
Browse files Browse the repository at this point in the history
  • Loading branch information
mmerickel committed Apr 4, 2023
1 parent a42ae00 commit 3e6cc89
Show file tree
Hide file tree
Showing 44 changed files with 90 additions and 125 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[flake8]
max-line-length = 79
max-line-length = 88
ignore =
# E203: whitespace before ':' (black fails to be PEP8 compliant)
E203
Expand Down
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
unreleased
==========

- Drop Python 3.5, and 3.6.

- Add Python 3.9, 3.10, 3.11.

0.3 (2020-11-29)
================

Expand Down
6 changes: 2 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os
import pkg_resources
import sys

# If extensions (or modules to document with autodoc) are in another
# directory, add these directories to sys.path here. If the directory is
Expand Down Expand Up @@ -241,9 +241,7 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'wired', u'wired Documentation', [u'Michael Merickel'], 1)
]
man_pages = [('index', 'wired', u'wired Documentation', [u'Michael Merickel'], 1)]

# If true, show URL addresses after external links.
# man_show_urls = False
Expand Down
2 changes: 1 addition & 1 deletion docs/dc/attributes/app.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# app.py
from dataclasses import dataclass, field

from venusian import Scanner

from wired import ServiceRegistry

from . import models


Expand Down
2 changes: 1 addition & 1 deletion docs/dc/attributes/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# models.py
from dataclasses import dataclass

from wired.dataclasses import factory, injected, Context
from wired.dataclasses import Context, factory, injected


@factory()
Expand Down
2 changes: 1 addition & 1 deletion docs/dc/attributes/request.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# request.py
from .models import Greeter, Customer, FrenchCustomer
from .models import Customer, FrenchCustomer, Greeter


def process_request(registry):
Expand Down
2 changes: 1 addition & 1 deletion docs/dc/decorators/app.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# app.py
from dataclasses import dataclass, field

from venusian import Scanner

from wired import ServiceRegistry

from . import models


Expand Down
2 changes: 1 addition & 1 deletion docs/dc/injected/app.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# app.py
from dataclasses import dataclass, field

from venusian import Scanner

from wired import ServiceRegistry

from . import models


Expand Down
2 changes: 1 addition & 1 deletion docs/dc/injected/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# models.py
from dataclasses import dataclass

from wired.dataclasses import factory, injected, Context
from wired.dataclasses import Context, factory, injected


@factory()
Expand Down
2 changes: 1 addition & 1 deletion docs/dc/injected/request.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# request.py
from .models import Greeter, Customer, FrenchCustomer
from .models import Customer, FrenchCustomer, Greeter


def process_request(registry):
Expand Down
2 changes: 1 addition & 1 deletion docs/dc/overrides/app.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# app.py
from dataclasses import dataclass, field

from venusian import Scanner

from wired import ServiceRegistry

from . import models


Expand Down
2 changes: 1 addition & 1 deletion docs/dc/overrides/request.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# request.py
from .models import Greeter, Customer, FrenchCustomer
from .models import Customer, FrenchCustomer, Greeter


def process_request(registry):
Expand Down
1 change: 1 addition & 0 deletions docs/dc/simple_construction/configure.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# configure.py
from wired import ServiceRegistry
from wired.dataclasses import register_dataclass

from .models import Greeter


Expand Down
2 changes: 1 addition & 1 deletion docs/dc/simple_injection/app.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# app.py
from dataclasses import dataclass, field

from venusian import Scanner

from wired import ServiceRegistry

from . import models


Expand Down
2 changes: 1 addition & 1 deletion docs/dc/singleton/app.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# app.py
from dataclasses import dataclass, field

from venusian import Scanner

from wired import ServiceRegistry

from . import models


Expand Down
4 changes: 1 addition & 3 deletions docs/tutorial/context/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ def french_greeter_factory(container) -> Greeter:

# Register it as a factory using its class for the "key", but
# this time register with a "context"
registry.register_factory(
french_greeter_factory, Greeter, context=FrenchCustomer
)
registry.register_factory(french_greeter_factory, Greeter, context=FrenchCustomer)

return registry

Expand Down
6 changes: 2 additions & 4 deletions docs/tutorial/datastore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from dataclasses import dataclass, field
from typing import List

from wired import ServiceRegistry, ServiceContainer
from wired import ServiceContainer, ServiceRegistry


@dataclass
Expand Down Expand Up @@ -87,9 +87,7 @@ def app_bootstrap(settings: Settings) -> ServiceRegistry:
return registry


def customer_interaction(
container: ServiceContainer, customer: Customer
) -> str:
def customer_interaction(container: ServiceContainer, customer: Customer) -> str:
"""Customer comes in, handle the steps in greeting them"""

# Get a Greeter using the customer as context. Use the Customer when
Expand Down
9 changes: 4 additions & 5 deletions docs/tutorial/datastore/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"""
from dataclasses import dataclass

from wired import ServiceRegistry, ServiceContainer
from . import Customer, Greeter, Settings, Datastore
from wired import ServiceContainer, ServiceRegistry

from . import Customer, Datastore, Greeter, Settings


@dataclass
Expand All @@ -30,9 +31,7 @@ def french_greeter_factory(container) -> Greeter:

# Register it as a factory using its class for the "key", but
# this time register with a "context"
registry.register_factory(
french_greeter_factory, Greeter, context=FrenchCustomer
)
registry.register_factory(french_greeter_factory, Greeter, context=FrenchCustomer)

# Grab the Datastore and add a FrenchCustomer
container: ServiceContainer = registry.create_container()
Expand Down
5 changes: 2 additions & 3 deletions docs/tutorial/decoupled/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from dataclasses import dataclass

from wired import ServiceRegistry

from . import Customer, Greeter, Settings


Expand All @@ -30,6 +31,4 @@ def french_greeter_factory(container) -> Greeter:

# Register it as a factory using its class for the "key", but
# this time register with a "context"
registry.register_factory(
french_greeter_factory, Greeter, context=FrenchCustomer
)
registry.register_factory(french_greeter_factory, Greeter, context=FrenchCustomer)
7 changes: 3 additions & 4 deletions docs/tutorial/overrides/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"""
from typing import List

from wired import ServiceRegistry, ServiceContainer
from wired import ServiceContainer, ServiceRegistry

from .models import Customer, Datastore, Greeter, Settings


Expand Down Expand Up @@ -62,9 +63,7 @@ def app_bootstrap(settings: Settings) -> ServiceRegistry:
return registry


def customer_interaction(
container: ServiceContainer, customer: Customer
) -> str:
def customer_interaction(container: ServiceContainer, customer: Customer) -> str:
"""Customer comes in, handle the steps in greeting them"""

# Get a Greeter using the customer as context. Use the Customer when
Expand Down
13 changes: 5 additions & 8 deletions docs/tutorial/overrides/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"""
from dataclasses import dataclass

from wired import ServiceRegistry, ServiceContainer
from .models import Customer, Greeter, Settings, Datastore
from wired import ServiceContainer, ServiceRegistry

from .models import Customer, Datastore, Greeter, Settings


@dataclass
Expand All @@ -34,9 +35,7 @@ def french_greeter_factory(container) -> Greeter:

# Register it as a factory using its class for the "key", but
# this time register with a "context"
registry.register_factory(
french_greeter_factory, Greeter, context=FrenchCustomer
)
registry.register_factory(french_greeter_factory, Greeter, context=FrenchCustomer)

# *** OVERRIDE !!! This add-on replaces the core, built-in Greeter
# with a different implementation.
Expand All @@ -45,9 +44,7 @@ def override_greeter_factory(container) -> Greeter:

# Register it as a factory using its class for the "key", but
# this time register with a "context"
registry.register_factory(
override_greeter_factory, Greeter, context=Customer
)
registry.register_factory(override_greeter_factory, Greeter, context=Customer)

# Grab the Datastore and add a FrenchCustomer
container: ServiceContainer = registry.create_container()
Expand Down
12 changes: 2 additions & 10 deletions docs/tutorial/requests_views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,8 @@
from typing import List

from wired import ServiceRegistry
from .models import (
Customer,
Datastore,
Greeter,
Resource,
Request,
Settings,
Url,
View,
)

from .models import Customer, Datastore, Greeter, Request, Resource, Settings, Url, View


def app_bootstrap(settings: Settings) -> ServiceRegistry:
Expand Down
9 changes: 4 additions & 5 deletions docs/tutorial/requests_views/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"""
from dataclasses import dataclass

from wired import ServiceRegistry, ServiceContainer
from .models import Customer, Greeter, Settings, Datastore
from wired import ServiceContainer, ServiceRegistry

from .models import Customer, Datastore, Greeter, Settings


@dataclass
Expand All @@ -29,9 +30,7 @@ def french_greeter_factory(container) -> Greeter:

# Register it as a factory using its class for the "key", but
# this time register with a "context"
registry.register_factory(
french_greeter_factory, Greeter, context=FrenchCustomer
)
registry.register_factory(french_greeter_factory, Greeter, context=FrenchCustomer)

# Grab the Datastore and add a FrenchCustomer
container: ServiceContainer = registry.create_container()
Expand Down
16 changes: 9 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ requires = ["setuptools>=41.0.1", "wheel"]
build-backend = "setuptools.build_meta"

[tool.black]
line-length = 79
target-version = ['py37', 'py38', 'py39', 'py310', 'py311']
skip-string-normalization = true
py36 = false

# This next section only exists for people that have their editors
# This next section only exists for people that have their editors
# automatically call isort, black already sorts entries on its own when run.
[tool.isort]
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
profile = "black"
combine_as_imports = true
line_length = 79
line_length = 88
force_sort_within_sections = true
no_lines_before = "THIRDPARTY"
sections = "FUTURE,THIRDPARTY,FIRSTPARTY,LOCALFOLDER"
default_section = "THIRDPARTY"
known_first_party = "wired"
3 changes: 1 addition & 2 deletions src/wired/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
__all__ = ['ServiceContainer', 'ServiceRegistry', 'service_factory']

from .container import ServiceContainer
from .container import ServiceRegistry
from .container import ServiceContainer, ServiceRegistry
from .decorators import service_factory
18 changes: 4 additions & 14 deletions src/wired/container.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import weakref
from zope.interface import Interface, implementedBy, providedBy
from zope.interface.adapter import AdapterRegistry
from zope.interface.interface import InterfaceClass
from zope.interface.interfaces import IInterface
from zope.interface.adapter import AdapterRegistry


__all__ = ['ServiceContainer', 'ServiceRegistry']

Expand Down Expand Up @@ -150,12 +149,7 @@ def bind(self, *, context):
)

def get(
self,
iface_or_type=Interface,
*,
context=_marker,
name='',
default=_marker
self, iface_or_type=Interface, *, context=_marker, name='', default=_marker
):
"""
Find a cached instance or create one from the registered factory.
Expand Down Expand Up @@ -208,9 +202,7 @@ def get(

# lookup in the global registry
if svc_info is None:
svc_info = _find_factory(
self._factories, iface, context_iface, name
)
svc_info = _find_factory(self._factories, iface, context_iface, name)

if svc_info is None:
if default is not _marker:
Expand All @@ -236,9 +228,7 @@ def get(
)
return inst

def set(
self, service, iface_or_type=Interface, *, context=_marker, name=''
):
def set(self, service, iface_or_type=Interface, *, context=_marker, name=''):
"""
Add a service instance to the container.
Expand Down
Loading

0 comments on commit 3e6cc89

Please sign in to comment.