Skip to content

Commit

Permalink
flake8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lowell80 committed Oct 14, 2023
1 parent d6cd521 commit 1b14715
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 15 deletions.
2 changes: 0 additions & 2 deletions docs/source/_static/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#
# KSCONF Official example app building script
#
# NOTE: Keep in mind that this is all very experimental and subject to change.
import sys
from pathlib import Path

from ksconf.builder import QUIET, VERBOSE, BuildManager, BuildStep, default_cli
Expand Down
11 changes: 8 additions & 3 deletions ksconf/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import platform
import sys
from collections import defaultdict
from typing import List
from typing import TYPE_CHECKING, Any, List

import ksconf.util
import ksconf.version as ksc
Expand All @@ -36,6 +36,11 @@
def choice(options):
return options[0]

if TYPE_CHECKING:
from pluggy import HookCaller, HookImpl
else:
HookCaller = HookImpl = Any


###################################################################################################
# CLI definition
Expand Down Expand Up @@ -151,9 +156,9 @@ def build_cli_parser(do_formatter=False):
version_info.append(f" plugins: {getattr(plugin, '__name__', repr(plugin))}")

workaround_dups = set()
hookcallers = plugin_manager.get_hookcallers(plugin) # type: List[_HookCaller]
hookcallers: List[HookCaller] = plugin_manager.get_hookcallers(plugin)
for caller in hookcallers:
hookimpls = caller.get_hookimpls() # type: List[HookImpl]
hookimpls: List[HookImpl] = caller.get_hookimpls()
parts = []
show = False
if len(hookimpls) > 1 or hookimpls[0].function.__name__ != caller.name:
Expand Down
2 changes: 1 addition & 1 deletion ksconf/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

__all__ = [
"KsconfCmd",
"ConfDirProxy"
"ConfDirProxy",
"ConfFileProxy",
"ConfFileType",
"dedent",
Expand Down
14 changes: 9 additions & 5 deletions ksconf/commands/attr.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" SUBCOMMAND: ``ksconf attr-get <CONF> --stanza STANZA --attribute ATTR``
"""r SUBCOMMAND: ``ksconf attr-get <CONF> --stanza STANZA --attribute ATTR``
.. code-block:: sh
Expand All @@ -7,14 +7,18 @@
SUBCOMMAND: ``ksconf attr-set <CONF> --stanza STANZA --attribute ATTR --value VALUE``
ksconf attr-set $SPLUNK_HOME/etc/apps/Splunk_TA_aws/local/app.conf --stanza launcher --attribute version --value 9.9.9
.. code-block:: sh
ksconf attr-set $SPLUNK_HOME/etc/apps/Splunk_TA_aws/local/app.conf \
--stanza launcher --attribute version --value 9.9.9
echo "9.9.9" > /tmp/new_version
ksconf attr-set $SPLUNK_HOME/etc/apps/Splunk_TA_aws/local/app.conf --stanza launcher --attribute version -t file /tmp/new_version
ksconf attr-set $SPLUNK_HOME/etc/apps/Splunk_TA_aws/local/app.conf \
--stanza launcher --attribute version -t file /tmp/new_version
export NEW_VERSION=1.2.3
ksconf attr-set $SPLUNK_HOME/etc/apps/Splunk_TA_aws/local/app.conf --stanza launcher --attribute version -t env NEW_VERSION
ksconf attr-set $SPLUNK_HOME/etc/apps/Splunk_TA_aws/local/app.conf \
--stanza launcher --attribute version -t env NEW_VERSION
"""

Expand Down
2 changes: 1 addition & 1 deletion ksconf/commands/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import os

from ksconf.command import KsconfCmd, add_file_handler, dedent
from ksconf.consts import EXIT_CODE_BAD_ARGS, EXIT_CODE_CLI_ARG_DEPRECATED, EXIT_CODE_SUCCESS
from ksconf.consts import EXIT_CODE_BAD_ARGS, EXIT_CODE_SUCCESS
from ksconf.layer import layer_file_factory
from ksconf.package import AppPackager

Expand Down
13 changes: 10 additions & 3 deletions ksconf/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@
from ksconf.conf.parser import GLOBAL_STANZA
from ksconf.util.file import splglob_to_regex

# It seems like each item on the list should be capability of having it's own type and flags (which could be inherited, at may not be known at the time the rules are first initialized)
# The should still be some phase that each "Rule" goes though (1) creation to set core attributes, (2) prep where things can be compiled, syntax checked, and any default flags should be available by this time, and (3) evaluate against a specific value for true/false.
# This would allow things like a special prefix to lazy-switch modes (for example: ~regex~, or only do fnmatching if there's a wildcard otherwise stick with simple string matching, ...)
# Note on future direction:
#
# It seems like each item on the list should be capable of having it's own type and flags (which
# could be inherited, at may not be known at the time the rules are first initialized).
#
# There should still be a phase that each "Rule" goes though to (1) set core attributes, (2) prep
# things that can be compiled, syntax checked, and any default flags should be available by this
# time, and (3) evaluate against a specific values for true/false. This would allow things like a
# special prefix to lazy-switch modes (for example: ~regex~, or only do fnmatching if there's a
# wildcard otherwise stick with simple string matching, for efficiency...)


class FilteredList:
Expand Down
3 changes: 3 additions & 0 deletions ksconf/plugins/_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
def modify_jinja_env(env):
pass
'''

# Keep flake8 happy
del ksconf_hook

0 comments on commit 1b14715

Please sign in to comment.