Ask Solem 8 anos atrás
pai
commit
991f8af804

+ 1 - 10
Makefile

@@ -8,7 +8,6 @@ ICONV=iconv
 FLAKE8=flake8
 PYDOCSTYLE=pydocstyle
 PYROMA=pyroma
-FLAKEPLUS=flakeplus
 SPHINX2RST=sphinx2rst
 RST2HTML=rst2html.py
 DEVNULL=/dev/null
@@ -23,7 +22,6 @@ CONTRIBUTING=CONTRIBUTING.rst
 CONTRIBUTING_SRC="docs/contributing.rst"
 SPHINX_HTMLDIR="${SPHINX_BUILDDIR}/html"
 DOCUMENTATION=Documentation
-FLAKEPLUSTARGET=2.7
 
 WORKER_GRAPH="docs/images/worker_graph_full.png"
 
@@ -41,7 +39,6 @@ help:
 	@echo "    contribcheck     - Check CONTRIBUTING.rst encoding"
 	@echo "    flakes --------  - Check code for syntax and style errors."
 	@echo "      flakecheck     - Run flake8 on the source code."
-	@echo "      flakepluscheck - Run flakeplus on the source code."
 	@echo "      pep257check    - Run pep257 on the source code."
 	@echo "readme               - Regenerate README.rst file."
 	@echo "contrib              - Regenerate CONTRIBUTING.rst file"
@@ -98,13 +95,7 @@ pep257check:
 flakediag:
 	-$(MAKE) flakecheck
 
-flakepluscheck:
-	$(FLAKEPLUS) --$(FLAKEPLUSTARGET) "$(PROJ)" "$(TESTDIR)"
-
-flakeplusdiag:
-	-$(MAKE) flakepluscheck
-
-flakes: flakediag flakeplusdiag pep257check
+flakes: flakediag pep257check
 
 clean-readme:
 	-rm -f $(README)

+ 2 - 3
celery/bin/call.py

@@ -2,7 +2,6 @@
 from __future__ import absolute_import, unicode_literals
 from kombu.utils.json import loads
 from celery.bin.base import Command
-from celery.five import string_t
 from celery.utils.time import maybe_iso8601
 
 
@@ -51,8 +50,8 @@ class call(Command):
                    queue=None, exchange=None, routing_key=None,
                    eta=None, expires=None, **_):
         # arguments
-        args = loads(args) if isinstance(args, string_t) else args
-        kwargs = loads(kwargs) if isinstance(kwargs, string_t) else kwargs
+        args = loads(args) if isinstance(args, str) else args
+        kwargs = loads(kwargs) if isinstance(kwargs, str) else kwargs
 
         # Expires can be int/float.
         try:

+ 1 - 0
celery/bin/celery.py

@@ -328,6 +328,7 @@ def main(argv=None):
 
 class multi(Command):
     """Start multiple worker instances."""
+
     fake_app = True
     requires_app = False
 

+ 2 - 3
celery/bin/control.py

@@ -2,7 +2,6 @@
 from __future__ import absolute_import, unicode_literals
 from kombu.utils.json import dumps
 from kombu.utils.objects import cached_property
-from celery.five import items, string_t
 from celery.bin.base import Command
 from celery.platforms import EX_UNAVAILABLE, EX_USAGE
 from celery.utils import text
@@ -95,7 +94,7 @@ class _RemoteControl(Command):
         self._ensure_fanout_supported()
 
         timeout = timeout or meta.default_timeout
-        if destination and isinstance(destination, string_t):
+        if destination and isinstance(destination, str):
             destination = [dest.strip() for dest in destination.split(',')]
 
         replies = self.call(
@@ -152,7 +151,7 @@ class _RemoteControl(Command):
         app.loader.import_default_modules()
 
         return {
-            name: info for name, info in items(Panel.meta)
+            name: info for name, info in Panel.meta.items()
             if info.type == cls.control_group and info.visible
         }
 

+ 1 - 2
celery/bin/purge.py

@@ -1,6 +1,5 @@
 """The ``celery purge`` program, used to delete messages from queues."""
 from __future__ import absolute_import, unicode_literals
-from celery.five import keys
 from celery.bin.base import Command
 from celery.utils import text
 
@@ -40,7 +39,7 @@ class purge(Command):
     def run(self, force=False, queues=None, exclude_queues=None, **kwargs):
         queues = set(text.str_to_list(queues or []))
         exclude = set(text.str_to_list(exclude_queues or []))
-        names = (queues or set(keys(self.app.amqp.queues))) - exclude
+        names = (queues or set(self.app.amqp.queues.keys())) - exclude
         qnum = len(names)
 
         messages = None

+ 1 - 2
celery/bin/shell.py

@@ -3,7 +3,6 @@ from __future__ import absolute_import, unicode_literals
 import os
 import sys
 from importlib import import_module
-from celery.five import values
 from celery.bin.base import Command
 
 
@@ -83,7 +82,7 @@ class shell(Command):  # pragma: no cover
 
         if not without_tasks:
             self.locals.update({
-                task.__name__: task for task in values(self.app.tasks)
+                task.__name__: task for task in self.app.tasks.values()
                 if not task.name.startswith('celery.')
             })
 

+ 4 - 2
celery/bootsteps.py

@@ -83,8 +83,7 @@ class Step(metaclass=StepType):
         pass
 
     def include_if(self, parent):
-        """An optional predicate that decides whether this
-        step should be created."""
+        """Return True if bootstep should be included."""
         return self.enabled
 
     def instantiate(self, name, *args, **kwargs):
@@ -114,6 +113,7 @@ class Step(metaclass=StepType):
 
 
 class StartStopStep(Step):
+    """Bootstep that is started and stopped."""
 
     #: Optional obj created by the :meth:`create` method.
     #: This is used by :class:`StartStopStep` to keep the
@@ -144,6 +144,8 @@ class StartStopStep(Step):
 
 
 class ConsumerStep(StartStopStep):
+    """Bootstep that starts message consumer."""
+
     requires = ('celery.worker.consumer:Connection',)
     consumers = None
 

+ 6 - 2
celery/utils/collections.py

@@ -246,8 +246,12 @@ class ChainMap(MutableMapping):
         return cls(dict.fromkeys(iterable, *args))
 
     def copy(self) -> 'ChainMap':
-        """New ChainMap or subclass with a new copy of maps[0] and
-        refs to maps[1:]."""
+        """Copy chainmap.
+
+        Returns:
+            ChainMap: new chainmap or subclass with a new copy of
+            ``maps[0]`` and refs to ``maps[1:]``.
+        """
         return self.__class__(self.maps[0].copy(), *self.maps[1:])
 
     def _iter(self, op: Callable[[Mapping], Iterator]) -> Iterator:

+ 1 - 1
celery/utils/deprecated.py

@@ -71,8 +71,8 @@ def Property(deprecation: Optional[str]=None,
              removal: Optional[str]=None,
              alternative: Optional[str]=None,
              description: Optional[str]=None) -> Callable:
+    """Decorator for deprecated properties."""
     def _inner(fun: Callable) -> Any:
-        """Decorator for deprecated properties."""
         return _deprecated_property(
             fun, deprecation=deprecation, removal=removal,
             alternative=alternative, description=description or fun.__name__)

+ 1 - 0
celery/utils/functional.py

@@ -48,6 +48,7 @@ class mlazy(lazy):
     The function is only evaluated once, every subsequent access
     will return the same value.
     """
+
     #: Set to :const:`True` after the object has been evaluated.
     evaluated = False  # type: bool
     _value = None      # type: Any

+ 1 - 2
celery/utils/serialization.py

@@ -254,8 +254,7 @@ def jsonify(obj: Any,
 
 
 def maybe_reraise() -> None:
-    """Re-raise if an exception is currently being handled, or return
-    otherwise."""
+    """Re-raise the current exception if any, or do nothing."""
     exc_info = sys.exc_info()
     try:
         if exc_info[2]:

+ 1 - 0
celery/utils/typing.py

@@ -1,3 +1,4 @@
+"""Static types."""
 from datetime import datetime, timedelta
 from numbers import Number
 

+ 0 - 1
requirements/pkgutils.txt

@@ -1,7 +1,6 @@
 setuptools>=20.6.7
 wheel>=0.29.0
 flake8>=2.5.4
-flakeplus>=1.1
 pydocstyle
 tox>=2.3.1
 sphinx2rst>=1.0

+ 2 - 2
t/unit/bin/test_call.py

@@ -1,9 +1,9 @@
 from __future__ import absolute_import, unicode_literals
+import io
 import pytest
 from datetime import datetime
 from case import patch
 from kombu.utils.json import dumps
-from celery.five import WhateverIO
 from celery.bin.call import call
 
 
@@ -18,7 +18,7 @@ class test_call:
 
     @patch('celery.app.base.Celery.send_task')
     def test_run(self, send_task):
-        a = call(app=self.app, stderr=WhateverIO(), stdout=WhateverIO())
+        a = call(app=self.app, stderr=io.StringIO(), stdout=io.StringIO())
         a.run(self.add.name)
         send_task.assert_called()
 

+ 3 - 3
t/unit/bin/test_control.py

@@ -1,7 +1,7 @@
 from __future__ import absolute_import, unicode_literals
+import io
 import pytest
 from case import Mock, patch
-from celery.five import WhateverIO
 from celery.bin.base import Error
 from celery.bin.control import _RemoteControl, inspect, control, status
 
@@ -57,7 +57,7 @@ class test_inspect:
 
     @patch('celery.app.control.Control.inspect')
     def test_run(self, real):
-        out = WhateverIO()
+        out = io.StringIO()
         i = inspect(app=self.app, stdout=out)
         with pytest.raises(Error):
             i.run()
@@ -112,7 +112,7 @@ class test_status:
 
     @patch('celery.bin.control.inspect')
     def test_run(self, inspect_):
-        out, err = WhateverIO(), WhateverIO()
+        out, err = io.StringIO(), io.StringIO()
         ins = inspect_.return_value = Mock()
         ins.run.return_value = []
         s = status(self.app, stdout=out, stderr=err)

+ 3 - 3
t/unit/bin/test_list.py

@@ -1,7 +1,7 @@
 from __future__ import absolute_import, unicode_literals
+import io
 import pytest
 from case import Mock
-from kombu.five import WhateverIO
 from celery.bin.base import Error
 from celery.bin.list import list_
 
@@ -9,14 +9,14 @@ from celery.bin.list import list_
 class test_list:
 
     def test_list_bindings_no_support(self):
-        l = list_(app=self.app, stderr=WhateverIO())
+        l = list_(app=self.app, stderr=io.StringIO())
         management = Mock()
         management.get_bindings.side_effect = NotImplementedError()
         with pytest.raises(Error):
             l.list_bindings(management)
 
     def test_run(self):
-        l = list_(app=self.app, stderr=WhateverIO())
+        l = list_(app=self.app, stderr=io.StringIO())
         l.run('bindings')
 
         with pytest.raises(Error):

+ 3 - 3
t/unit/bin/test_migrate.py

@@ -1,7 +1,7 @@
 from __future__ import absolute_import, unicode_literals
+import io
 import pytest
 from case import Mock, patch
-from celery.five import WhateverIO
 from celery.bin.migrate import migrate
 
 
@@ -9,8 +9,8 @@ class test_migrate:
 
     @patch('celery.contrib.migrate.migrate_tasks')
     def test_run(self, migrate_tasks):
-        out = WhateverIO()
-        m = migrate(app=self.app, stdout=out, stderr=WhateverIO())
+        out = io.StringIO()
+        m = migrate(app=self.app, stdout=out, stderr=io.StringIO())
         with pytest.raises(TypeError):
             m.run()
         migrate_tasks.assert_not_called()

+ 2 - 2
t/unit/bin/test_purge.py

@@ -1,13 +1,13 @@
 from __future__ import absolute_import, unicode_literals
+import io
 from case import Mock
-from celery.five import WhateverIO
 from celery.bin.purge import purge
 
 
 class test_purge:
 
     def test_run(self):
-        out = WhateverIO()
+        out = io.StringIO()
         a = purge(app=self.app, stdout=out)
         a._purge = Mock(name='_purge')
         a._purge.return_value = 0

+ 2 - 2
t/unit/bin/test_result.py

@@ -1,6 +1,6 @@
 from __future__ import absolute_import, unicode_literals
+import io
 from case import patch
-from celery.five import WhateverIO
 from celery.bin.result import result
 
 
@@ -15,7 +15,7 @@ class test_result:
 
     def test_run(self):
         with patch('celery.result.AsyncResult.get') as get:
-            out = WhateverIO()
+            out = io.StringIO()
             r = result(app=self.app, stdout=out)
             get.return_value = 'Jerry'
             r.run('id')

+ 2 - 7
tox.ini

@@ -4,7 +4,6 @@ envlist =
     {2.7,pypy,3.4,3.5,pypy3}-integration-{rabbitmq,redis}
 
     flake8
-    flakeplus
     apicheck
     configcheck
     pydocstyle
@@ -21,7 +20,7 @@ deps=
     integration: -r{toxinidir}/requirements/test-integration.txt
 
     linkcheck,apicheck,configcheck: -r{toxinidir}/requirements/docs.txt
-    flake8,flakeplus,pydocstyle: -r{toxinidir}/requirements/pkgutils.txt
+    flake8,pydocstyle: -r{toxinidir}/requirements/pkgutils.txt
 sitepackages = False
 recreate = False
 commands =
@@ -42,7 +41,7 @@ basepython =
     3.5: python3.5
     pypy: pypy
     pypy3: pypy3
-    flake8,flakeplus,apicheck,linkcheck,configcheck,pydocstyle: python2.7
+    flake8,apicheck,linkcheck,configcheck,pydocstyle: python2.7
 
 [testenv:apicheck]
 commands =
@@ -60,10 +59,6 @@ commands =
 commands =
     flake8 {toxinidir}/celery {toxinidir}/t
 
-[testenv:flakeplus]
-commands =
-    flakeplus --2.7 {toxinidir}/celery {toxinidir}/t
-
 [testenv:pydocstyle]
 commands =
     pydocstyle {toxinidir}/celery