Issue 1:
Checklist

I have verified that the issue exists against the master branch of Celery.

This has already been asked to the discussion group first.

I have read the relevant section in the

contribution guide

on reporting bugs.

I have checked the issues list

for similar or identical bug reports.

I have checked the pull requests list

for existing proposed fixes.

I have checked the commit log

to find out if the bug was already fixed in the master branch.

I have included all related issues and possible duplicate issues

in this issue (If there are none, check this box anyway).

Mandatory Debugging Information

I have included the output of celery -A proj report in the issue.

(if you are not able to do this, then at least specify the Celery

version affected).

I have verified that the issue exists against the master branch of Celery.

I have included the contents of pip freeze in the issue.

I have included all the versions of all the external dependencies required

to reproduce this bug.

Optional Debugging Information

I have tried reproducing the issue on more than one Python version

and/or implementation.

I have tried reproducing the issue on more than one message broker and/or

result backend.

I have tried reproducing the issue on more than one version of the message

broker and/or result backend.

I have tried reproducing the issue on more than one operating system.

I have tried reproducing the issue on more than one workers pool.

I have tried reproducing the issue with autoscaling, retries,

ETA/Countdown & rate limits disabled.

I have tried reproducing the issue after downgrading

and/or upgrading Celery and its dependencies.

Related Issues and Possible Duplicates

Related Issues

None

Possible Duplicates

None

Environment & Settings

Celery version:

celery report Output:

software -> celery:5.0.5 (singularity) kombu:5.0.2 py:3.6.9
billiard:3.6.4.0 py-amqp:5.0.6
platform -> system:Linux arch:64bit, ELF
kernel version:4.15.0-140-generic imp:CPython
loader -> celery.loaders.default.Loader
settings -> transport:amqp results:mongodb+srv://md_app_user:**@md-mongo.privatecircle.co/master_docs

accept_content: ['json']
broker_url: 'amqp://md_app_user:********@****************:5672//master_docs'
default_timezone: 'Asia/Kolkata'
imports: ['tasks']
result_backend: 'mongodb+srv://md_app_user:********@******************/master_docs'
result_serializer: 'json'
task_serializer: 'json'
timezone: 'Asia/Kolkata'
deprecated_settings: None

Steps to Reproduce

Required Dependencies

Minimal Python Version: 3.6.9

Minimal Celery Version: 5.0.3

Minimal Kombu Version: 5.0.2

Minimal Broker Version: RabbitMQ 3.8.11

Minimal Result Backend Version: Mongo 4.4

Minimal OS and/or Kernel Version: Ubuntu 18.04.5 (Linux kernel 4.15.0-140)

Minimal Broker Client Version: N/A or Unknown

Minimal Result Backend Client Version: N/A or Unknown

Python Packages

pip freeze Output:

amqp==5.0.6
backcall==0.2.0
billiard==3.6.4.0
boto3==1.17.51
botocore==1.20.51
cached-property==1.5.2
cchardet==2.1.7
celery==5.0.5
certifi==2020.12.5
chardet==4.0.0
click==7.1.2
click-didyoumean==0.0.3
click-plugins==1.1.1
click-repl==0.1.6
decorator==5.0.6
dnspython==2.1.0
idna==2.10
importlib-metadata==3.10.0
ipython==7.16.1
ipython-genutils==0.2.0
jedi==0.17.2
jmespath==0.10.0
kombu==5.0.2
lxml==4.6.3
parso==0.7.1
pexpect==4.8.0
pickleshare==0.7.5
prompt-toolkit==3.0.18
ptyprocess==0.7.0
Pygments==2.8.1
pymongo==3.11.3
python-dateutil==2.8.1
python-magic==0.4.22
pytz==2021.1
requests==2.25.1
s3transfer==0.3.6
six==1.15.0
traitlets==4.3.3
typing-extensions==3.7.4.3
urllib3==1.26.4
vine==5.0.0
wcwidth==0.2.5
zipp==3.4.1

Other Dependencies

N/A

Minimally Reproducible Test Case

# test.py
import celery
app = celery.Celery('proj')

$ celery -A test amqp repl
> exchange.declare

Expected Behavior

The AMQP interactive shell should accept this command and execute it and then prompt for the next command.

Actual Behavior

Traceback (most recent call last):
File "/home/privatecircle/.virtualenvs/mca_document_manager/bin/celery", line 8, in <module>
sys.exit(main())
File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/celery/__main__.py", line 15, in main
sys.exit(_main())
File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/celery/bin/celery.py", line 213, in main
return celery(auto_envvar_prefix="CELERY")
File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click_repl/__init__.py", line 248, in repl
group.invoke(ctx)
File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py", line 1256, in invoke
Command.invoke(self, ctx)
File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/click/decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/privatecircle/.virtualenvs/mca_document_manager/lib/python3.6/site-packages/celery/bin/base.py", line 120, in caller
app = ctx.obj.app
AttributeError: 'AMQPContext' object has no attribute 'app'

Issue 2:
F821 is one of the most useful flake8 rules, however it's currently disabled because type comments reference undefined names.

it can be fixed with a conditional dependency on typing or importing typing in an if False: block, see discussion here: PyCQA/pyflakes#501

conditional dep

# requirements.txt
typing; python_version < '3.5'

# some_annotated.py
from typing import Any, Tuple

if typing.TYPE_CHECKING:
from celery import Celery

if False:

# some_annotated.py

if False:
from typing import Any, Tuple
from celery import Celery

@auvipy @thedrow do you have a preferred typing import approach? mine is to add the conditional dep

Checklist

I have checked the issues list

for similar or identical enhancement to an existing feature.

I have checked the pull requests list

for existing proposed enhancements.

I have checked the commit log

to find out if the if the same enhancement was already implemented in the

master branch.

I have included all related issues and possible duplicate issues in this issue

(If there are none, check this box anyway).

Related Issues and Possible Duplicates

Related Issues

None

Possible Duplicates

None

Brief Summary

Design

Architectural Considerations

None

Proposed Behavior

Proposed UI/UX

Diagrams

N/A

Alternatives

None