#noqa magic comment in python

Adding #noqa to a line means that the linter (a program that automatically checks the quality of the code) should not check this line. Any warnings that the code may have generated will be ignored.

This line may have something that “looks bad” to the …


This content originally appeared on DEV Community and was authored by Vadim Kolobanov

Adding #noqa to a line means that the linter (a program that automatically checks the quality of the code) should not check this line. Any warnings that the code may have generated will be ignored.

This line may have something that "looks bad" to the linter, but the developer understands and intends to do it for some reason.

Noqa = NO-QA (NO Quality Assurance)

Simply put, lines with #noga at the end will be ignored by linter programs and will not issue any warnings.

Just leave a comment #noqa at the end of the line that triggers a warning from linter, and he will stop paying attention to it.

The most interesting thing is that I got acquainted with NOQA in the root files of the Django framework. The developers just decided to ignore the warnings in some of their imports. Look better visually

from django.core.exceptions import ObjectDoesNotExist
from django.db.models import signals
from django.db.models.aggregates import *  # NOQA
from django.db.models.aggregates import __all__ as aggregates_all
from django.db.models.constraints import *  # NOQA
from django.db.models.constraints import __all__ as constraints_all
from django.db.models.deletion import (
    CASCADE, DO_NOTHING, PROTECT, RESTRICT, SET, SET_DEFAULT, SET_NULL,
    ProtectedError, RestrictedError,
)
from django.db.models.enums import *  # NOQA
from django.db.models.enums import __all__ as enums_all
from django.db.models.expressions import (
    Case, Exists, Expression, ExpressionList, ExpressionWrapper, F, Func,
    OrderBy, OuterRef, RowRange, Subquery, Value, ValueRange, When, Window,
    WindowFrame,
)
from django.db.models.fields import *  # NOQA
from django.db.models.fields import __all__ as fields_all
from django.db.models.fields.files import FileField, ImageField
from django.db.models.fields.json import JSONField
from django.db.models.fields.proxy import OrderWrt
from django.db.models.indexes import *  # NOQA
from django.db.models.indexes import __all__ as indexes_all
from django.db.models.lookups import Lookup, Transform
from django.db.models.manager import Manager
from django.db.models.query import Prefetch, QuerySet, prefetch_related_objects
from django.db.models.query_utils import FilteredRelation, Q

If you want to find it yourself, look in django.db.models

Good Luck!

You can also find me on Medium. I will be very glad to have
your attention.

Become a patron


This content originally appeared on DEV Community and was authored by Vadim Kolobanov


Print Share Comment Cite Upload Translate Updates
APA

Vadim Kolobanov | Sciencx (2021-11-03T04:31:00+00:00) #noqa magic comment in python. Retrieved from https://www.scien.cx/2021/11/03/noqa-magic-comment-in-python/

MLA
" » #noqa magic comment in python." Vadim Kolobanov | Sciencx - Wednesday November 3, 2021, https://www.scien.cx/2021/11/03/noqa-magic-comment-in-python/
HARVARD
Vadim Kolobanov | Sciencx Wednesday November 3, 2021 » #noqa magic comment in python., viewed ,<https://www.scien.cx/2021/11/03/noqa-magic-comment-in-python/>
VANCOUVER
Vadim Kolobanov | Sciencx - » #noqa magic comment in python. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/11/03/noqa-magic-comment-in-python/
CHICAGO
" » #noqa magic comment in python." Vadim Kolobanov | Sciencx - Accessed . https://www.scien.cx/2021/11/03/noqa-magic-comment-in-python/
IEEE
" » #noqa magic comment in python." Vadim Kolobanov | Sciencx [Online]. Available: https://www.scien.cx/2021/11/03/noqa-magic-comment-in-python/. [Accessed: ]
rf:citation
» #noqa magic comment in python | Vadim Kolobanov | Sciencx | https://www.scien.cx/2021/11/03/noqa-magic-comment-in-python/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.