Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove -> None annotation from __init__ #472

Merged
merged 2 commits into from
Jan 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/prefect/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _initialize_logger(self) -> None:
self.logger.addHandler(handler)
self.logger.setLevel(prefect.config.logging.level)

def __init__(self, api_server: str = None, graphql_server: str = None) -> None:
def __init__(self, api_server: str = None, graphql_server: str = None):
self._initialize_logger()
if not api_server:
api_server = prefect.config.cloud.get("api", None)
Expand Down
2 changes: 1 addition & 1 deletion src/prefect/client/secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Secret:
of the `use_local_secrets` flag in your Prefect configuration file.
"""

def __init__(self, name: str) -> None:
def __init__(self, name: str):
self.name = name

def get(self) -> Optional[str]:
Expand Down
2 changes: 1 addition & 1 deletion src/prefect/core/edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__(
downstream_task: Task,
key: str = None,
mapped: bool = False,
) -> None:
):
self.upstream_task = upstream_task
self.downstream_task = downstream_task
self.mapped = mapped
Expand Down
2 changes: 1 addition & 1 deletion src/prefect/core/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def __init__(
state_handlers: Iterable[Callable] = None,
validate: bool = None,
result_handler: ResultHandler = None,
) -> None:
):
self._cache = {} # type: dict

# set random id
Expand Down
4 changes: 2 additions & 2 deletions src/prefect/core/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def __init__(
cache_for: timedelta = None,
cache_validator: Callable = None,
state_handlers: Iterable[Callable] = None,
) -> None:
):

self.name = name or type(self).__name__
self.slug = slug
Expand Down Expand Up @@ -842,7 +842,7 @@ def __init__(
default: Any = None,
required: bool = True,
tags: Iterable[str] = None,
) -> None:
):
if default is not None:
required = False

Expand Down
2 changes: 1 addition & 1 deletion src/prefect/engine/executors/dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(
processes: bool = False,
debug: bool = config.debug,
**kwargs: Any
) -> None:
):
self.address = address
self.processes = processes
self.debug = debug
Expand Down
2 changes: 1 addition & 1 deletion src/prefect/engine/flow_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __init__(
flow: Flow,
task_runner_cls: type = None,
state_handlers: Iterable[Callable] = None,
) -> None:
):
self.flow = flow
self.task_runner_cls = task_runner_cls or TaskRunner
self.client = Client()
Expand Down
4 changes: 2 additions & 2 deletions src/prefect/engine/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ENDRUN(Exception):
stop. The pipeline result should be the state contained in the exception.
"""

def __init__(self, state: State) -> None:
def __init__(self, state: State):
"""
Args
- state (State): the state that should be used as the result of the Runner's run
Expand Down Expand Up @@ -63,7 +63,7 @@ def inner(self: "Runner", state: State, *args: Any, **kwargs: Any) -> State:


class Runner:
def __init__(self, state_handlers: Iterable[Callable] = None) -> None:
def __init__(self, state_handlers: Iterable[Callable] = None):
if state_handlers is not None and not isinstance(
state_handlers, collections.Sequence
):
Expand Down
2 changes: 1 addition & 1 deletion src/prefect/engine/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PrefectStateSignal(PrefectError):

_state_cls = state.State

def __init__(self, message=None, *args, **kwargs) -> None: # type: ignore
def __init__(self, message: str = None, *args, **kwargs): # type: ignore
super().__init__(message) # type: ignore
self.state = self._state_cls( # type: ignore
result=self, message=message, *args, **kwargs
Expand Down
20 changes: 9 additions & 11 deletions src/prefect/engine/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class State:

color = "#000000"

def __init__(self, message: str = None, result: Any = None) -> None:
def __init__(self, message: str = None, result: Any = None):
self.message = message
self.result = result

Expand Down Expand Up @@ -202,7 +202,7 @@ def __init__(
message: str = None,
result: Any = None,
cached_inputs: Dict[str, Any] = None,
) -> None:
):
super().__init__(message=message, result=result)
self.cached_inputs = cached_inputs

Expand Down Expand Up @@ -249,7 +249,7 @@ def __init__(
cached_result: Any = None,
cached_parameters: Dict[str, Any] = None,
cached_result_expiration: datetime.datetime = None,
) -> None:
):
super().__init__(message=message, result=result, cached_inputs=cached_inputs)
self.cached_result = cached_result
self.cached_parameters = cached_parameters
Expand Down Expand Up @@ -279,7 +279,7 @@ def __init__(
result: Any = None,
start_time: datetime.datetime = None,
cached_inputs: Dict[str, Any] = None,
) -> None:
):
super().__init__(message=message, result=result, cached_inputs=cached_inputs)
self.start_time = ensure_tz_aware(start_time or pendulum.now("utc"))

Expand All @@ -304,9 +304,7 @@ class Submitted(State):

"""

def __init__(
self, message: str = None, result: Any = None, state: State = None
) -> None:
def __init__(self, message: str = None, result: Any = None, state: State = None):
super().__init__(message=message, result=result)
self.state = state

Expand Down Expand Up @@ -352,7 +350,7 @@ def __init__(
start_time: datetime.datetime = None,
cached_inputs: Dict[str, Any] = None,
run_count: int = None,
) -> None:
):
super().__init__(
result=result,
message=message,
Expand Down Expand Up @@ -418,7 +416,7 @@ class Success(Finished):

def __init__(
self, message: str = None, result: Any = None, cached: CachedState = None
) -> None:
):
super().__init__(message=message, result=result)
self.cached = cached

Expand Down Expand Up @@ -473,7 +471,7 @@ def __init__(
message: str = None,
result: Any = None,
cached_inputs: Dict[str, Any] = None,
) -> None:
):
super().__init__(message=message, result=result)
self.cached_inputs = cached_inputs

Expand Down Expand Up @@ -504,5 +502,5 @@ class Skipped(Success):
color = "#F0FFF0"

# note: this does not allow setting "cached" as Success states do
def __init__(self, message: str = None, result: Any = None) -> None:
def __init__(self, message: str = None, result: Any = None):
super().__init__(message=message, result=result)
2 changes: 1 addition & 1 deletion src/prefect/engine/task_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __init__(
task: Task,
result_handler: ResultHandler = None,
state_handlers: Iterable[Callable] = None,
) -> None:
):
self.task = task
self.client = Client()
self.result_handler = result_handler
Expand Down
6 changes: 2 additions & 4 deletions src/prefect/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ class LocalEnvironment(Environment):
- serialized_flow (bytes): a serialized flow. This is usually generated by calling `build()`.
"""

def __init__(
self, encryption_key: bytes = None, serialized_flow: bytes = None
) -> None:
def __init__(self, encryption_key: bytes = None, serialized_flow: bytes = None):
if encryption_key is None:
encryption_key = Fernet.generate_key()
else:
Expand Down Expand Up @@ -237,7 +235,7 @@ def __init__(
image_tag: str = None,
env_vars: dict = None,
files: dict = None,
) -> None:
):
self.base_image = base_image
self.registry_url = registry_url
self.image_name = image_name
Expand Down
4 changes: 2 additions & 2 deletions src/prefect/schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class IntervalSchedule(Schedule):

def __init__(
self, start_date: datetime, interval: timedelta, end_date: datetime = None
) -> None:
):
if not isinstance(start_date, datetime):
raise TypeError("`start_date` must be a datetime.")
elif interval.total_seconds() < 60:
Expand Down Expand Up @@ -131,7 +131,7 @@ class CronSchedule(Schedule):

def __init__(
self, cron: str, start_date: datetime = None, end_date: datetime = None
) -> None:
):
# build cron object to check the cron string - will raise an error if it's invalid
CronTab(cron)
self.cron = cron
Expand Down
2 changes: 1 addition & 1 deletion src/prefect/tasks/control_flow/conditional.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Match(Task):
- **kwargs: keyword arguments for the Task
"""

def __init__(self, match_value: Any, **kwargs) -> None:
def __init__(self, match_value: Any, **kwargs):
self.match_value = match_value
kwargs.setdefault("name", 'match: "{}"'.format(match_value))
super().__init__(**kwargs)
Expand Down
2 changes: 1 addition & 1 deletion src/prefect/tasks/core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class Constant(prefect.Task):
def __init__(self, value: Any, name: str = None, **kwargs: Any) -> None:
def __init__(self, value: Any, name: str = None, **kwargs: Any):

self.value = value

Expand Down
2 changes: 1 addition & 1 deletion src/prefect/tasks/core/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class FunctionTask(prefect.Task):
```
"""

def __init__(self, fn: Callable, name: str = None, **kwargs: Any) -> None:
def __init__(self, fn: Callable, name: str = None, **kwargs: Any):
if not callable(fn):
raise TypeError("fn must be callable.")

Expand Down
4 changes: 2 additions & 2 deletions src/prefect/tasks/database/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SQLiteQueryTask(Task):
standard Task initalization
"""

def __init__(self, db: str, query: str = None, **kwargs) -> None:
def __init__(self, db: str, query: str = None, **kwargs):
self.db = db
self.query = query
super().__init__(**kwargs)
Expand Down Expand Up @@ -56,7 +56,7 @@ class SQLiteScriptTask(Task):
standard Task initialization
"""

def __init__(self, db: str, script: str = None, **kwargs) -> None:
def __init__(self, db: str, script: str = None, **kwargs):
self.db = db
self.script = script
super().__init__(**kwargs)
Expand Down
2 changes: 1 addition & 1 deletion src/prefect/tasks/flow_runner_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class FlowRunnerTask(prefect.Task):
def __init__(
self, executor: prefect.engine.executors.Executor = None, **kwargs: Any
) -> None:
):
self.executor = executor
super().__init__(**kwargs)

Expand Down
4 changes: 1 addition & 3 deletions src/prefect/tasks/notifications/email_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ class EmailTask(prefect.Task):
This task sends an email.
"""

def __init__(
self, username: str = None, password: str = None, **kwargs: Any
) -> None:
def __init__(self, username: str = None, password: str = None, **kwargs: Any):

self.username = username
self.password = password
Expand Down
2 changes: 1 addition & 1 deletion src/prefect/tasks/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ShellTask(prefect.Task):

def __init__(
self, shell: str = "bash", cd: str = None, command: str = None, **kwargs: Any
) -> None:
):
self.shell = shell
self.cd = cd
self.command = command
Expand Down
2 changes: 1 addition & 1 deletion src/prefect/tasks/templates/jinja2.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class JinjaTemplateTask(Task):
standard Task constructor
"""

def __init__(self, template: str = None, **kwargs: Any) -> None:
def __init__(self, template: str = None, **kwargs: Any):
self.template = Template(template or "")
super().__init__(**kwargs)

Expand Down
2 changes: 1 addition & 1 deletion src/prefect/tasks/templates/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class StringFormatterTask(Task):
standard Task constructor
"""

def __init__(self, template: str = None, **kwargs: Any) -> None:
def __init__(self, template: str = None, **kwargs: Any):
self.template = template or ""
super().__init__(**kwargs)

Expand Down
4 changes: 2 additions & 2 deletions src/prefect/utilities/airflow_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def custom_query(db: str, query: str) -> List:


class AirTask(prefect.tasks.shell.ShellTask):
def __init__(self, task: "airflow.models.BaseOperator", **kwargs: Any) -> None:
def __init__(self, task: "airflow.models.BaseOperator", **kwargs: Any):
name = task.task_id
dag_id = task.dag_id
trigger = trigger_mapping[task.trigger_rule]
Expand Down Expand Up @@ -164,7 +164,7 @@ def __init__(
db_file: str = None,
dag_folder: str = None,
**kwargs: Any
) -> None:
):
self.dag = airflow.models.DagBag(dag_folder=dag_folder).dags[dag_id]
super().__init__(*args, **kwargs)
self._populate_tasks()
Expand Down
16 changes: 15 additions & 1 deletion src/prefect/utilities/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,25 @@ class DotDict(MutableMapping):

__protect_critical_keys__ = True

def __init__(self, init_dict: DictLike = None, **kwargs: Any) -> None:
def __init__(self, init_dict: DictLike = None, **kwargs: Any):
if init_dict:
self.update(init_dict)
self.update(kwargs)

def get(self, key: str, default: Any = None) -> Any:
"""
This method is defined for MyPy, which otherwise tries to type
the inherited `.get()` method incorrectly.

Args:
- key (str): the key to retrieve
- default (Any): a default value to return if the key is not found

Returns:
- Any: the value of the key, or the default value if the key is not found
"""
return super().get(key, default)

def __getitem__(self, key: str) -> Any:
return self.__dict__[key] # __dict__ expects string keys

Expand Down
2 changes: 1 addition & 1 deletion src/prefect/utilities/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Context(DotDict, threading.local):
A thread safe context store for Prefect data.
"""

def __init__(self, *args, **kwargs):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
if "context" in config:
self.update(config.context)
Expand Down
2 changes: 1 addition & 1 deletion src/prefect/utilities/graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class EnumValue:
as enum values, without quotation marks.
"""

def __init__(self, value: str) -> None:
def __init__(self, value: str):
self.value = value

def __str__(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion src/prefect/utilities/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


class RemoteHandler(logging.StreamHandler):
def __init__(self):
def __init__(self) -> None:
super().__init__()
self.logger_server = config.cloud.log
self.client = None
Expand Down
Loading