Skip to content

Commit 8d438c3

Browse files
committed
Resolve cyclic imports
1 parent b583b21 commit 8d438c3

19 files changed

Lines changed: 107 additions & 182 deletions

.basedpyright/baseline.json

Lines changed: 2 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -16090,64 +16090,6 @@
1609016090
}
1609116091
}
1609216092
],
16093-
"./splunklib/modularinput/__init__.py": [
16094-
{
16095-
"code": "reportUnusedImport",
16096-
"range": {
16097-
"startColumn": 22,
16098-
"endColumn": 30,
16099-
"lineCount": 1
16100-
}
16101-
},
16102-
{
16103-
"code": "reportUnusedImport",
16104-
"range": {
16105-
"startColumn": 19,
16106-
"endColumn": 24,
16107-
"lineCount": 1
16108-
}
16109-
},
16110-
{
16111-
"code": "reportUnusedImport",
16112-
"range": {
16113-
"startColumn": 26,
16114-
"endColumn": 37,
16115-
"lineCount": 1
16116-
}
16117-
},
16118-
{
16119-
"code": "reportUnusedImport",
16120-
"range": {
16121-
"startColumn": 30,
16122-
"endColumn": 45,
16123-
"lineCount": 1
16124-
}
16125-
},
16126-
{
16127-
"code": "reportUnusedImport",
16128-
"range": {
16129-
"startColumn": 20,
16130-
"endColumn": 26,
16131-
"lineCount": 1
16132-
}
16133-
},
16134-
{
16135-
"code": "reportUnusedImport",
16136-
"range": {
16137-
"startColumn": 20,
16138-
"endColumn": 26,
16139-
"lineCount": 1
16140-
}
16141-
},
16142-
{
16143-
"code": "reportUnusedImport",
16144-
"range": {
16145-
"startColumn": 35,
16146-
"endColumn": 55,
16147-
"lineCount": 1
16148-
}
16149-
}
16150-
],
1615116093
"./splunklib/modularinput/argument.py": [
1615216094
{
1615316095
"code": "reportUnannotatedClassAttribute",
@@ -41713,38 +41655,6 @@
4171341655
}
4171441656
],
4171541657
"./tests/unit/modularinput/modularinput_testlib.py": [
41716-
{
41717-
"code": "reportUnusedImport",
41718-
"range": {
41719-
"startColumn": 7,
41720-
"endColumn": 15,
41721-
"lineCount": 1
41722-
}
41723-
},
41724-
{
41725-
"code": "reportUnusedImport",
41726-
"range": {
41727-
"startColumn": 41,
41728-
"endColumn": 52,
41729-
"lineCount": 1
41730-
}
41731-
},
41732-
{
41733-
"code": "reportUnusedImport",
41734-
"range": {
41735-
"startColumn": 54,
41736-
"endColumn": 68,
41737-
"lineCount": 1
41738-
}
41739-
},
41740-
{
41741-
"code": "reportUnusedImport",
41742-
"range": {
41743-
"startColumn": 70,
41744-
"endColumn": 86,
41745-
"lineCount": 1
41746-
}
41747-
},
4174841658
{
4174941659
"code": "reportUnknownParameterType",
4175041660
"range": {
@@ -41764,8 +41674,8 @@
4176441674
{
4176541675
"code": "reportUnknownArgumentType",
4176641676
"range": {
41767-
"startColumn": 65,
41768-
"endColumn": 73,
41677+
"startColumn": 76,
41678+
"endColumn": 84,
4176941679
"lineCount": 1
4177041680
}
4177141681
}
@@ -42089,46 +41999,6 @@
4208941999
}
4209042000
],
4209142001
"./tests/unit/modularinput/test_script.py": [
42092-
{
42093-
"code": "reportPrivateLocalImportUsage",
42094-
"range": {
42095-
"startColumn": 35,
42096-
"endColumn": 41,
42097-
"lineCount": 1
42098-
}
42099-
},
42100-
{
42101-
"code": "reportPrivateLocalImportUsage",
42102-
"range": {
42103-
"startColumn": 43,
42104-
"endColumn": 54,
42105-
"lineCount": 1
42106-
}
42107-
},
42108-
{
42109-
"code": "reportPrivateLocalImportUsage",
42110-
"range": {
42111-
"startColumn": 56,
42112-
"endColumn": 62,
42113-
"lineCount": 1
42114-
}
42115-
},
42116-
{
42117-
"code": "reportPrivateLocalImportUsage",
42118-
"range": {
42119-
"startColumn": 64,
42120-
"endColumn": 72,
42121-
"lineCount": 1
42122-
}
42123-
},
42124-
{
42125-
"code": "reportPrivateLocalImportUsage",
42126-
"range": {
42127-
"startColumn": 74,
42128-
"endColumn": 79,
42129-
"lineCount": 1
42130-
}
42131-
},
4213242002
{
4213342003
"code": "reportUnknownVariableType",
4213442004
"range": {

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ lint: lint-python # TODO: Add mbake
2626

2727
.PHONY: lint-python
2828
lint-python:
29-
# $(UV_RUN_CMD) basedpyright
29+
$(UV_RUN_CMD) basedpyright
3030
# $(UV_RUN_CMD) ruff check --fix-only
3131
$(UV_RUN_CMD) ruff format
3232

@@ -36,7 +36,7 @@ ci-lint: ci-lint-python # TODO: Add mbake
3636

3737
.PHONY: ci-lint-python
3838
ci-lint-python:
39-
# $(UV_RUN_CMD) basedpyright
39+
$(UV_RUN_CMD) basedpyright
4040
# $(UV_RUN_CMD) ruff check
4141
$(UV_RUN_CMD) ruff format --check
4242

splunklib/modularinput/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,13 @@
1111
from .scheme import Scheme
1212
from .script import Script
1313
from .validation_definition import ValidationDefinition
14+
15+
__all__ = [
16+
"Argument",
17+
"Event",
18+
"EventWriter",
19+
"InputDefinition",
20+
"Scheme",
21+
"Script",
22+
"ValidationDefinition",
23+
]

splunklib/searchcommands/__init__.py

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,63 @@
136136
137137
2. `Create Custom Search Commands with commands.conf.spec <http://docs.splunk.com/Documentation/Splunk/latest/Admin/Commandsconf>`_
138138
139-
3. `Configure seach assistant with searchbnf.conf <https://docs.splunk.com/Documentation/Splunk/latest/Admin/Searchbnfconf>`_
139+
3. `Configure search assistant with searchbnf.conf <https://docs.splunk.com/Documentation/Splunk/latest/Admin/Searchbnfconf>`_
140140
141141
4. `Control search distribution with distsearch.conf <https://docs.splunk.com/Documentation/Splunk/latest/Admin/Distsearchconf>`_
142142
143143
"""
144144

145-
from .decorators import *
146-
from .environment import *
147-
from .eventing_command import EventingCommand
148-
from .external_search_command import ExternalSearchCommand, execute
149-
from .generating_command import GeneratingCommand
150-
from .reporting_command import ReportingCommand
151-
from .search_command import SearchMetric, dispatch
152-
from .streaming_command import StreamingCommand
153-
from .validators import *
145+
from splunklib.searchcommands.decorators import Configuration, Option
146+
from splunklib.searchcommands.environment import (
147+
app_file,
148+
app_root,
149+
logging_configuration, # pyright: ignore[reportUnknownVariableType]
150+
splunk_home,
151+
splunklib_logger,
152+
)
153+
from splunklib.searchcommands.eventing_command import EventingCommand
154+
from splunklib.searchcommands.external_search_command import ExternalSearchCommand, execute
155+
from splunklib.searchcommands.generating_command import GeneratingCommand
156+
from splunklib.searchcommands.reporting_command import ReportingCommand
157+
from splunklib.searchcommands.search_command import SearchMetric, dispatch
158+
from splunklib.searchcommands.streaming_command import StreamingCommand
159+
from splunklib.searchcommands.validators import (
160+
Boolean,
161+
Code,
162+
Duration,
163+
File,
164+
Float,
165+
Integer,
166+
List,
167+
Map,
168+
RegularExpression,
169+
Set,
170+
)
171+
172+
__all__ = [
173+
"Boolean",
174+
"Code",
175+
"Configuration",
176+
"Duration",
177+
"EventingCommand",
178+
"ExternalSearchCommand",
179+
"File",
180+
"Float",
181+
"GeneratingCommand",
182+
"Integer",
183+
"List",
184+
"Map",
185+
"Option",
186+
"RegularExpression",
187+
"ReportingCommand",
188+
"SearchMetric",
189+
"Set",
190+
"StreamingCommand",
191+
"app_file",
192+
"app_root",
193+
"dispatch",
194+
"execute",
195+
"logging_configuration",
196+
"splunk_home",
197+
"splunklib_logger",
198+
]

splunklib/searchcommands/decorators.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515

1616
from collections import OrderedDict
1717
from inspect import getmembers, isclass, isfunction
18+
from json.encoder import encode_basestring_ascii as json_encode_string
1819

19-
from .internals import ConfigurationSettingsType, json_encode_string
20-
from .validators import OptionName
20+
from splunklib.searchcommands.internals import ConfigurationSettingsType
21+
from splunklib.searchcommands.validators import OptionName
2122

2223

2324
class Configuration:

splunklib/searchcommands/eventing_command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
# under the License.
1414

1515

16-
from .decorators import ConfigurationSetting
17-
from .search_command import SearchCommand
16+
from splunklib.searchcommands.decorators import ConfigurationSetting
17+
from splunklib.searchcommands.search_command import SearchCommand
1818

1919

2020
class EventingCommand(SearchCommand):

splunklib/searchcommands/external_search_command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import traceback
1818
from logging import getLogger
1919

20-
from . import splunklib_logger as logger
20+
from splunklib.searchcommands.environment import splunklib_logger as logger
2121

2222
if sys.platform == "win32":
2323
import atexit

splunklib/searchcommands/generating_command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
import sys
1616

17-
from .decorators import ConfigurationSetting
18-
from .search_command import SearchCommand
17+
from splunklib.searchcommands.decorators import ConfigurationSetting
18+
from splunklib.searchcommands.search_command import SearchCommand
1919

2020
# P1 [O] TODO: Discuss generates_timeorder in the class-level documentation for GeneratingCommand
2121

splunklib/searchcommands/internals.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import csv
1616
import gzip
17-
import os
1817
import re
1918
import sys
2019
import urllib.parse
@@ -25,7 +24,7 @@
2524
from json import JSONDecoder, JSONEncoder
2625
from json.encoder import encode_basestring_ascii as json_encode_string
2726

28-
from . import environment
27+
from splunklib.searchcommands.environment import splunklib_logger
2928

3029
csv.field_size_limit(
3130
10485760
@@ -109,7 +108,7 @@ def parse(cls, command, argv):
109108
``ValueError``: Unrecognized option/field name, or an illegal field value.
110109
111110
"""
112-
debug = environment.splunklib_logger.debug
111+
debug = splunklib_logger.debug
113112
command_class = type(command).__name__
114113

115114
# Prepare

splunklib/searchcommands/reporting_command.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
# under the License.
1414

1515
from itertools import chain
16+
from json.encoder import encode_basestring_ascii as json_encode_string
1617

17-
from .decorators import ConfigurationSetting, Option
18-
from .internals import ConfigurationSettingsType, json_encode_string
19-
from .search_command import SearchCommand
20-
from .streaming_command import StreamingCommand
21-
from .validators import Set
18+
from splunklib.searchcommands.decorators import ConfigurationSetting, Option
19+
from splunklib.searchcommands.internals import ConfigurationSettingsType
20+
from splunklib.searchcommands.search_command import SearchCommand
21+
from splunklib.searchcommands.streaming_command import StreamingCommand
22+
from splunklib.searchcommands.validators import Set
2223

2324

2425
class ReportingCommand(SearchCommand):

0 commit comments

Comments
 (0)