Skip to content

Commit

Permalink
Merge branch 'main' into feat-handle-sync-abort
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Payne authored Mar 30, 2023
2 parents f989bb4 + 55b54c2 commit 3ae02e8
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 40 deletions.
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,17 @@ exclude = [
"cookiecutter/*",
]
ignore = [
"ANN101",
"ANN102",
"ANN101", # Missing type annotation for `self` in method
"ANN102", # Missing type annotation for `cls` in class method
"N818", # Exception name should be named with an Error suffix
]
line-length = 88
select = [
"F", # Pyflakes
"E", # pycodestyle (error)
"W", # pycodestyle (warning)
"I", # isort
"N", # pep8-naming
"D", # pydocstyle/flake8-docstrings
"UP", # pyupgrade
"YTT", # flake8-2020
Expand Down
2 changes: 1 addition & 1 deletion samples/sample_tap_bigquery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class BigQueryConnector(SQLConnector):
"""Connects to the BigQuery SQL source."""

def get_sqlalchemy_url(cls, config: dict) -> str:
def get_sqlalchemy_url(self, config: dict) -> str:
"""Concatenate a SQLAlchemy URL for use in connecting to the source."""
return f"bigquery://{config['project_id']}"

Expand Down
16 changes: 8 additions & 8 deletions singer_sdk/_singerlib/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ class Schema:
description: str | None = None
minimum: float | None = None
maximum: float | None = None
exclusiveMinimum: float | None = None
exclusiveMaximum: float | None = None
multipleOf: float | None = None
maxLength: int | None = None
minLength: int | None = None
anyOf: t.Any | None = None
exclusiveMinimum: float | None = None # noqa: N815
exclusiveMaximum: float | None = None # noqa: N815
multipleOf: float | None = None # noqa: N815
maxLength: int | None = None # noqa: N815
minLength: int | None = None # noqa: N815
anyOf: t.Any | None = None # noqa: N815
format: str | None = None # noqa: A003
additionalProperties: t.Any | None = None
patternProperties: t.Any | None = None
additionalProperties: t.Any | None = None # noqa: N815
patternProperties: t.Any | None = None # noqa: N815
required: list[str] | None = None
enum: list[t.Any] | None = None
title: str | None = None
Expand Down
2 changes: 1 addition & 1 deletion singer_sdk/helpers/capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def __getitem__(self, name: str) -> Any: # noqa: ANN401
obj.emit_warning()
return obj

def __getattribute__(cls, name: str) -> Any: # noqa: ANN401
def __getattribute__(cls, name: str) -> Any: # noqa: ANN401, N805
"""Retrieve enum attribute.
Args:
Expand Down
4 changes: 2 additions & 2 deletions singer_sdk/mapper_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class InlineMapper(PluginBase, SingerReader, metaclass=abc.ABCMeta):
"""Abstract base class for inline mappers."""

@classproperty
def _env_prefix(cls) -> str:
def _env_prefix(cls) -> str: # noqa: N805
return f"{cls.name.upper().replace('-', '_')}_"

@classproperty
Expand Down Expand Up @@ -111,7 +111,7 @@ def map_batch_message(
raise NotImplementedError("BATCH messages are not supported by mappers.")

@classproperty
def cli(cls) -> Callable:
def cli(cls) -> Callable: # noqa: N805
"""Execute standard CLI handler for inline mappers.
Returns:
Expand Down
16 changes: 8 additions & 8 deletions singer_sdk/plugin_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,22 @@ class PluginBase(metaclass=abc.ABCMeta):
_config: dict

@classproperty
def logger(cls) -> logging.Logger:
def logger(cls) -> logging.Logger: # noqa: N805
"""Get logger.
Returns:
Plugin logger.
"""
# Get the level from <PLUGIN_NAME>_LOGLEVEL or LOGLEVEL environment variables
plugin_env_prefix = f"{cls.name.upper().replace('-', '_')}_"
LOGLEVEL = os.environ.get(f"{plugin_env_prefix}LOGLEVEL") or os.environ.get(
log_level = os.environ.get(f"{plugin_env_prefix}LOGLEVEL") or os.environ.get(
"LOGLEVEL",
)

logger = logging.getLogger(cls.name)

if LOGLEVEL is not None and LOGLEVEL.upper() in logging._levelToName.values():
logger.setLevel(LOGLEVEL.upper())
if log_level is not None and log_level.upper() in logging._levelToName.values():
logger.setLevel(log_level.upper())

return logger

Expand Down Expand Up @@ -132,7 +132,7 @@ def capabilities(self) -> list[CapabilitiesEnum]:
]

@classproperty
def _env_var_config(cls) -> dict[str, Any]:
def _env_var_config(cls) -> dict[str, Any]: # noqa: N805
"""Return any config specified in environment variables.
Variables must match the convention "<PLUGIN_NAME>_<SETTING_NAME>",
Expand All @@ -150,7 +150,7 @@ def _env_var_config(cls) -> dict[str, Any]:
# Core plugin metadata:

@classproperty
def plugin_version(cls) -> str:
def plugin_version(cls) -> str: # noqa: N805
"""Get version.
Returns:
Expand All @@ -163,7 +163,7 @@ def plugin_version(cls) -> str:
return version

@classproperty
def sdk_version(cls) -> str:
def sdk_version(cls) -> str: # noqa: N805
"""Return the package version number.
Returns:
Expand Down Expand Up @@ -400,7 +400,7 @@ def print_about(
print(formatted) # noqa: T201

@classproperty
def cli(cls) -> Callable:
def cli(cls) -> Callable: # noqa: N805
"""Handle command line execution.
Returns:
Expand Down
2 changes: 1 addition & 1 deletion singer_sdk/streams/graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class GraphQLStream(RESTStream, metaclass=abc.ABCMeta):
rest_method = "POST"

@classproperty
def records_jsonpath(cls) -> str: # type: ignore[override]
def records_jsonpath(cls) -> str: # type: ignore[override] # noqa: N805
"""Get the JSONPath expression to extract records from an API response.
Returns:
Expand Down
2 changes: 1 addition & 1 deletion singer_sdk/tap_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def sync_all(self) -> None:
# Command Line Execution

@classproperty
def cli(cls) -> Callable:
def cli(cls) -> Callable: # noqa: N805
"""Execute standard CLI handler for taps.
Returns:
Expand Down
2 changes: 1 addition & 1 deletion singer_sdk/target_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ def _write_state_message(self, state: dict) -> None:
# CLI handler

@classproperty
def cli(cls) -> Callable:
def cli(cls) -> Callable: # noqa: N805
"""Execute standard CLI handler for taps.
Returns:
Expand Down
16 changes: 8 additions & 8 deletions singer_sdk/testing/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def runner(self) -> TapTestRunner | TargetTestRunner:
)

if suite.kind in {"tap", "target"}:
for TestClass in suite.tests:
test = TestClass()
for test_class in suite.tests:
test = test_class()
test_name = f"test_{suite.kind}_{test.name}"
setattr(BaseTestClass, f"test_{suite.kind}_{test.name}", test.run)

Expand All @@ -89,8 +89,8 @@ def runner(self) -> TapTestRunner | TargetTestRunner:
]
param_ids = [stream.name for stream in streams]

for TestClass in suite.tests:
test = TestClass()
for test_class in suite.tests:
test = test_class()
test_name = f"test_{suite.kind}_{test.name}"
setattr(
BaseTestClass,
Expand All @@ -101,8 +101,8 @@ def runner(self) -> TapTestRunner | TargetTestRunner:
BaseTestClass.param_ids[test_name] = param_ids

if suite.kind == "tap_stream_attribute":
for TestClass in suite.tests:
test = TestClass()
for test_class in suite.tests:
test = test_class()
test_name = f"test_{suite.kind}_{test.name}"
test_params = []
test_ids = []
Expand All @@ -116,7 +116,7 @@ def runner(self) -> TapTestRunner | TargetTestRunner:
for property_name, property_schema in stream.schema[
"properties"
].items()
if TestClass.evaluate(
if test_class.evaluate(
stream=stream,
property_name=property_name,
property_schema=property_schema,
Expand All @@ -129,7 +129,7 @@ def runner(self) -> TapTestRunner | TargetTestRunner:
for property_name, property_schema in stream.schema[
"properties"
].items()
if TestClass.evaluate(
if test_class.evaluate(
stream=stream,
property_name=property_name,
property_schema=property_schema,
Expand Down
12 changes: 6 additions & 6 deletions singer_sdk/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class JSONTypeHelper:
"""Type helper base class for JSONSchema types."""

@classproperty
def type_dict(cls) -> dict:
def type_dict(cls) -> dict: # noqa: N805
"""Return dict describing the type.
Raises:
Expand Down Expand Up @@ -207,11 +207,11 @@ class StringType(JSONTypeHelper):
"""

@classproperty
def _format(cls) -> dict:
def _format(cls) -> dict: # noqa: N805
return {"format": cls.string_format} if cls.string_format else {}

@classproperty
def type_dict(cls) -> dict:
def type_dict(cls) -> dict: # noqa: N805
"""Get type dictionary.
Returns:
Expand Down Expand Up @@ -332,7 +332,7 @@ class BooleanType(JSONTypeHelper):
"""Boolean type."""

@classproperty
def type_dict(cls) -> dict:
def type_dict(cls) -> dict: # noqa: N805
"""Get type dictionary.
Returns:
Expand All @@ -345,7 +345,7 @@ class IntegerType(JSONTypeHelper):
"""Integer type."""

@classproperty
def type_dict(cls) -> dict:
def type_dict(cls) -> dict: # noqa: N805
"""Get type dictionary.
Returns:
Expand All @@ -358,7 +358,7 @@ class NumberType(JSONTypeHelper):
"""Number type."""

@classproperty
def type_dict(cls) -> dict:
def type_dict(cls) -> dict: # noqa: N805
"""Get type dictionary.
Returns:
Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def test_jsonpath_graphql_stream_override(tap: SimpleTestTap):

class GraphQLJSONPathOverride(GraphqlTestStream):
@classproperty
def records_jsonpath(cls):
def records_jsonpath(cls): # noqa: N805
return "$[*]"

stream = GraphQLJSONPathOverride(tap)
Expand Down

0 comments on commit 3ae02e8

Please sign in to comment.