Repository: PrefectHQ/prefect

Issue:
Four undefined names
[flake8](http://flake8.pycqa.org) testing of https://github.com/PrefectHQ/prefect on Python 3.7.1

$ __flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics__
```
./src/prefect/tasks/core/collections.py:32:15: F821 undefined name 'prefect'
        flow: "prefect.Flow" = None
              ^
./tests/test_configuration.py:193:12: F632 use ==/!= to compare str, bytes, and int literals
    assert configuration.string_to_type("1") is 1
           ^
./tests/test_configuration.py:205:12: F632 use ==/!= to compare str, bytes, and int literals
    assert config.env_vars.int is 10
           ^
./tests/engine/test_task_runner.py:313:12: F632 use ==/!= to compare str, bytes, and int literals
    assert state.result is "my_private_str"
           ^
./tests/engine/cloud/test_cloud_flows.py:573:49: F821 undefined name 'executor'
        CloudFlowRunner(flow=flow).run(executor=executor)
                                                ^
./tests/engine/cloud/test_cloud_flows.py:602:49: F821 undefined name 'executor'
        CloudFlowRunner(flow=flow).run(executor=executor)
                                                ^
./tests/serialization/test_edges.py:59:12: F632 use ==/!= to compare str, bytes, and int literals
    assert deserialized.upstream_task.name is "Task"
           ^
./tests/serialization/test_edges.py:60:12: F632 use ==/!= to compare str, bytes, and int literals
    assert deserialized.downstream_task.name is "Task"
           ^
./tests/serialization/test_states.py:93:12: F632 use ==/!= to compare str, bytes, and int literals
    assert serialized["message"] is "message"
           ^
./tests/serialization/test_states.py:104:12: F632 use ==/!= to compare str, bytes, and int literals
    assert serialized["message"] is "message"
           ^
./tests/serialization/test_states.py:117:12: F632 use ==/!= to compare str, bytes, and int literals
    assert serialized["message"] is "message"
           ^
./tests/serialization/test_states.py:130:12: F632 use ==/!= to compare str, bytes, and int literals
    assert serialized["message"] is "message"
           ^
./tests/serialization/test_states.py:142:12: F632 use ==/!= to compare str, bytes, and int literals
    assert serialized["message"] is "message"
           ^
./tests/core/test_flow_local_ids.py:19:16: F821 undefined name 'self'
        return self._name
               ^
10    F632 use ==/!= to compare str, bytes, and int literals
4     F821 undefined name 'prefect'
14
```
__E901,E999,F821,F822,F823__ are the "_showstopper_" [flake8](http://flake8.pycqa.org) issues that can halt the runtime with a SyntaxError, NameError, etc. These 5 are different from most other flake8 issues which are merely "style violations" -- useful for readability but they do not effect runtime safety.
* F821: undefined name `name`
* F822: undefined name `name` in `__all__`
* F823: local variable name referenced before assignment
* E901: SyntaxError or IndentationError
* E999: SyntaxError -- failed to compile a file into an Abstract Syntax Tree



Discussion:

Resolving patch:
diff --git a/src/prefect/tasks/core/collections.py b/src/prefect/tasks/core/collections.py
--- a/src/prefect/tasks/core/collections.py
+++ b/src/prefect/tasks/core/collections.py
@@ -7,6 +7,7 @@
 """
 from typing import Any, Iterable
 
+import prefect
 from prefect import Task
 
 
@@ -29,7 +30,7 @@ def bind(
         *args: Any,
         upstream_tasks: Iterable[Any] = None,
         mapped: bool = False,
-        flow: "prefect.Flow" = None
+        flow: prefect.Flow = None
     ) -> Task:
         """
         Args:


Test patch:
diff --git a/tests/core/test_flow_local_ids.py b/tests/core/test_flow_local_ids.py
--- a/tests/core/test_flow_local_ids.py
+++ b/tests/core/test_flow_local_ids.py
@@ -15,7 +15,7 @@ def __init__(self, _name):
         self._name = _name
         super().__init__()
 
-    def __repr__():
+    def __repr__(self):
         return self._name
 
 
diff --git a/tests/engine/cloud/test_cloud_flows.py b/tests/engine/cloud/test_cloud_flows.py
--- a/tests/engine/cloud/test_cloud_flows.py
+++ b/tests/engine/cloud/test_cloud_flows.py
@@ -570,7 +570,7 @@ def test_deep_map_with_a_retry(monkeypatch):
     )
 
     with prefect.context(flow_run_id=flow_run_id):
-        CloudFlowRunner(flow=flow).run(executor=executor)
+        CloudFlowRunner(flow=flow).run()
 
     assert client.flow_runs[flow_run_id].state.is_running()
     assert client.task_runs[task_run_id_1].state.is_mapped()
@@ -599,7 +599,7 @@ def test_deep_map_with_a_retry(monkeypatch):
 
     # RUN A SECOND TIME
     with prefect.context(flow_run_id=flow_run_id):
-        CloudFlowRunner(flow=flow).run(executor=executor)
+        CloudFlowRunner(flow=flow).run()
 
     # t2's first child task should be successful
     t2_0 = next(
diff --git a/tests/engine/test_task_runner.py b/tests/engine/test_task_runner.py
--- a/tests/engine/test_task_runner.py
+++ b/tests/engine/test_task_runner.py
@@ -310,7 +310,7 @@ def test_task_runner_handles_secrets():
     with set_temporary_config({"cloud.use_local_secrets": True}):
         state = TaskRunner(t).run(context=dict(secrets=dict(testing="my_private_str")))
     assert state.is_successful()
-    assert state.result is "my_private_str"
+    assert state.result == "my_private_str"
 
 
 def test_task_that_starts_failed_doesnt_get_retried():
diff --git a/tests/serialization/test_edges.py b/tests/serialization/test_edges.py
--- a/tests/serialization/test_edges.py
+++ b/tests/serialization/test_edges.py
@@ -56,8 +56,8 @@ def test_deserialize_edge_has_no_task_info():
     serialized = EdgeSchema().dump(Edge(t1, t2, key="x", mapped=True))
     deserialized = EdgeSchema().load(serialized)
 
-    assert deserialized.upstream_task.name is "Task"
-    assert deserialized.downstream_task.name is "Task"
+    assert deserialized.upstream_task.name == "Task"
+    assert deserialized.downstream_task.name == "Task"
 
 
 def test_deserialize_edge_uses_task_cache():
diff --git a/tests/serialization/test_states.py b/tests/serialization/test_states.py
--- a/tests/serialization/test_states.py
+++ b/tests/serialization/test_states.py
@@ -90,7 +90,7 @@ def test_serialize_state_with_un_handled_result(cls):
     serialized = StateSchema().dump(cls(message="message", result=1))
     assert isinstance(serialized, dict)
     assert serialized["type"] == cls.__name__
-    assert serialized["message"] is "message"
+    assert serialized["message"] == "message"
     assert serialized["_result"]["type"] == "NoResultType"
     assert serialized["__version__"] == prefect.__version__
 
@@ -101,7 +101,7 @@ def test_serialize_state_with_no_result(cls):
     serialized = StateSchema().dump(state)
     assert isinstance(serialized, dict)
     assert serialized["type"] == cls.__name__
-    assert serialized["message"] is "message"
+    assert serialized["message"] == "message"
     assert serialized["_result"]["type"] == "NoResultType"
     assert serialized["__version__"] == prefect.__version__
 
@@ -114,7 +114,7 @@ def test_serialize_state_with_handled_result(cls):
     serialized = StateSchema().dump(state)
     assert isinstance(serialized, dict)
     assert serialized["type"] == cls.__name__
-    assert serialized["message"] is "message"
+    assert serialized["message"] == "message"
     assert serialized["_result"]["type"] == "SafeResult"
     assert serialized["_result"]["value"] == "1"
     assert serialized["__version__"] == prefect.__version__
@@ -127,7 +127,7 @@ def test_serialize_state_with_safe_result(cls):
     serialized = StateSchema().dump(state)
     assert isinstance(serialized, dict)
     assert serialized["type"] == cls.__name__
-    assert serialized["message"] is "message"
+    assert serialized["message"] == "message"
     assert serialized["_result"]["type"] == "SafeResult"
     assert serialized["_result"]["value"] == "1"
     assert serialized["__version__"] == prefect.__version__
@@ -139,7 +139,7 @@ def test_serialize_mapped():
     serialized = StateSchema().dump(state.Mapped(message="message", map_states=[s, f]))
     assert isinstance(serialized, dict)
     assert serialized["type"] == "Mapped"
-    assert serialized["message"] is "message"
+    assert serialized["message"] == "message"
     assert "_result" not in serialized
     assert "map_states" not in serialized
     assert serialized["n_map_states"] == 2
diff --git a/tests/test_configuration.py b/tests/test_configuration.py
--- a/tests/test_configuration.py
+++ b/tests/test_configuration.py
@@ -190,7 +190,7 @@ def test_string_to_type_function():
     assert configuration.string_to_type("FALSE") is False
     assert configuration.string_to_type("falSe") is False
 
-    assert configuration.string_to_type("1") is 1
+    assert configuration.string_to_type("1") == 1
     assert configuration.string_to_type("1.5") == 1.5
 
     assert configuration.string_to_type("-1") == -1
@@ -202,7 +202,7 @@ def test_string_to_type_function():
 def test_env_var_interpolation_with_type_assignment(config):
     assert config.env_vars.true is True
     assert config.env_vars.false is False
-    assert config.env_vars.int is 10
+    assert config.env_vars.int == 10
     assert config.env_vars.negative_int == -10
     assert config.env_vars.float == 7.5
     assert config.env_vars.negative_float == -7.5