Skip to content

Commit

Permalink
feat: project uses plain dicts as ordered sets (for now), keep old xl…
Browse files Browse the repository at this point in the history
…oop behavior; upgrade python to 3.11+.
  • Loading branch information
joshorr committed Jan 3, 2024
1 parent 534bf00 commit fedaaf0
Show file tree
Hide file tree
Showing 7 changed files with 818 additions and 897 deletions.
1,671 changes: 795 additions & 876 deletions poetry.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ classifiers = [


[tool.poetry.dependencies]
python = "^3.8"
xbool = "^1.0.0"
xloop = "^1.0.1"
xsentinels = "^1.2.1"
xinject = "^1.3.0"
xboto = "^1.0.2"
xsettings = "^1.1.2"
ciso8601 = "^2.3.0"
python = "^3.11"
xbool = "^1.1.0"
xloop = "^1.1.0"
xsentinels = "^1.2.2"
xinject = "^1.4.1"
xboto = "^1.1.1"
xsettings = "^1.4.0"
ciso8601 = "^2.3.1"

[tool.poetry.group.dev.dependencies]
pytest-ordering = "^0.6"
Expand Down
10 changes: 6 additions & 4 deletions tests/normal_tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,14 @@ def test_direct_parent_behavior(directory: Directory):
config_providers = [
p for p in config.provider_chain.providers if not isinstance(p, ProviderCacher)
]
assert list(xloop(child.provider_chain.providers)) == list(xloop(config_providers))
assert list(
xloop(child.provider_chain.providers, default_not_iterate=[str])
) == list(xloop(config_providers, default_not_iterate=[str]))

child = Config(directories=["/hello/another"])

assert list(
xloop(child.directory_chain.directories)
xloop(child.directory_chain.directories, default_not_iterate=[str])
) == [Directory.from_path("/hello/another")]

assert child.cacher is Default
Expand All @@ -198,8 +200,8 @@ def test_direct_parent_behavior(directory: Directory):
p if not isinstance(p, ProviderCacher) else child.cacher
for p in config.provider_chain.providers
]
child_providers = list(xloop(child.provider_chain.providers))
parent_providers = list(xloop(config.provider_chain.providers))
child_providers = list(xloop(child.provider_chain.providers, default_not_iterate=[str]))
parent_providers = list(xloop(config.provider_chain.providers, default_not_iterate=[str]))
assert child_providers == parent_providers


Expand Down
12 changes: 6 additions & 6 deletions xcon/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __post_init__(self):
parents = self.parents
if not isinstance(parents, tuple):
# Convert to a tuple
object.__setattr__(self, 'parents', tuple(xloop(parents)))
object.__setattr__(self, 'parents', tuple(xloop(parents, default_not_iterate=[str])))

def start_cursor(self) -> Optional[_ParentCursor]:
"""
Expand Down Expand Up @@ -339,7 +339,7 @@ def __init__(

# This property will lazily be used to create self.provider_chain when the chain
# is requested for the first time.
self._providers = {x: None for x in xloop(providers)}
self._providers = {x: None for x in xloop(providers, default_not_iterate=[str])}

# We lazy-lookup cacher if it's Default or a Type.
# See 'self.cacher' property.
Expand Down Expand Up @@ -386,7 +386,7 @@ def directories(
"""
# make an ordered-set out of this.
dirs: OrderedDefaultSet = {}
for x in xloop(value):
for x in xloop(value, default_not_iterate=[str]):
if x is not Default:
x = Directory.from_path(x)
dirs[x] = None
Expand All @@ -400,7 +400,7 @@ def providers(self, value: Union[DefaultType, Iterable[Union[DefaultType, Type[P
when you ask for the `Config.provider_chain`.
"""
# make an ordered-set out of this.
self._providers = {x: None for x in xloop(value)}
self._providers = {x: None for x in xloop(value, default_not_iterate=[str])}

def add_provider(self, provider: Type[Provider]):
""" Adds a provider type to end of my provider type list [you can see what it is for
Expand Down Expand Up @@ -492,7 +492,7 @@ def set_exports(self, *, services: Iterable[Union[str, DefaultType]]):
to add by service name. If you don't add the `xsentinels.Default` somewhere in
this list then we will NOT check the parent-chain
"""
self._exports = {x: None for x in xloop(services)}
self._exports = {x: None for x in xloop(services, default_not_iterate=[str])}

def get_exports_by_service(self):
""" List of services we currently check their export's for. This only lists the exports
Expand Down Expand Up @@ -1399,7 +1399,7 @@ def _standard_directories(

return {
d.resolve(service=service, environment=environment): None
for d in xloop(xcon_settings.directories)
for d in xloop(xcon_settings.directories, default_not_iterate=[str])
}

def _service_with_cursor(self, cursor: Optional[_ParentCursor]) -> str:
Expand Down
2 changes: 1 addition & 1 deletion xcon/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ class DirectoryListing:
def __init__(self, directory: Directory = None, items: Iterable[DirectoryItem] = None):
self.directory = directory
self._items = {}
for item in xloop(items):
for item in xloop(items, default_not_iterate=[str]):
self.add_item(item)

def get_any_item(self) -> Optional[DirectoryItem]:
Expand Down
2 changes: 1 addition & 1 deletion xcon/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def __post_init__(self):
context = XContext.grab()
provider_key_names = []
query_before_finished = False
for p in xloop(self.providers):
for p in xloop(self.providers, default_not_iterate=[str]):
# Check to see if any of them are classes [and type's resources needs to be grabbed].
if isclass(p):
p = context.dependency(p)
Expand Down
2 changes: 1 addition & 1 deletion xcon/providers/dynamo.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def _get_items_for_environ(self, environ: Directory) -> Iterable[DirectoryItem]:
items = self._table.get_items_for_directory(directory=environ, expire_time=expire_time)

# Ensure we have a list, and not a generator.
items = tuple(xloop(items))
items = tuple(xloop(items, default_not_iterate=[str]))

# Log about stuff we retrieved from the cache table.
self.log_about_items(items=items, path=environ.path)
Expand Down

0 comments on commit fedaaf0

Please sign in to comment.