Variable in function should be lowercase python

[PYTHON] How to suppress Pycharm’s «pep8 indentation is not a multiple of four» and «Variable in function should be lower case» warnings

Is annoying everywhere, so I will put the setting method in Pycharm to suppress this on the back of the leaflet.

Setting method

  • ** How to remove Variable in function should be lower case **
  • Open ʻInspections with File → Setting and uncheck PEP 8 coding naming convention viloation`
  • ** How to erase pep8 indentation is not a multiple of four **
  • Open ʻInspections with File → Setting and select PEP 8 coding style viloation` on the search screen in the right pane.
  • Add ʻE111 to ʻIgnore errors and execute ʻApply`

Similar warnings in other development environments

  • If you use PEP8’s Linter in other development environments, you should usually have a setting to Ignore certain errors. For example, in the case of ATOM PEP8 Linter, if you write ‘ignoreErrorCodes’:’E111, E501′ in config.cson Looks good

Supplement about PEP8

About PEP8

  • PEP8 is roughly a Python Coding Rule. This article is very helpful
  • PEP8 Click here for Japanese translation
  • See here for a list of PEP8 Error Codes (http://pep8.readthedocs.org/en/latest/intro.html#error-codes)
Читайте также:  Start python from powershell

Major Coding Rules

  • About Indent
  • It is recommended to make one indent (Tab) with four Spaces
  • If you want to suppress this error, ignore E111 and E114
  • About function names and variable names
  • Function name, variable name: It is recommended to separate all lowercase letters with _ ( set_stream_logger etc.)
  • Class name: Upper Camel Case recommended (eg GetImageLocation )
  • Other than Pycharm, Flake8 (PEP8 Wrap library) and [pep8-naming (flake8 plugin)](https://github.com/flintwork/ It seems that you should put pep8-naming) and set it to ignore N802 / N806 etc. (I have not tried it)
  • 1 line length
  • Up to 79 characters per line is recommended
  • If you want to suppress this error, ignore E501
  • About Import Declaration
  • 1 line 1 library Import recommended
  • If you want to suppress this error, ignore E401
  • Whitespace before and after the operator
  • Insert a space before and after operators such as =, ==, , is, in, not in
  • If you want to suppress this error, ignore E221 and E222

About PEP8 Check Tool

There are two types of tools, pep8 and ʻautopep8`.

  • About pep8
  • Tool that tells you where to fix
  • Install with pip install pep8 and check pep8 xxx.py —show-source * If you specify .py, the error code and the corresponding part will be spit out as shown below.
  • If you want to ignore a particular Error, pep8 xxx.py —ignore = E111, E114, E501 —show-source E111 / 114 is ʻIndent Error , E501 is Line Too Long`
xxx.py:4:1: E302 expected 2 blank lines, found 1 def foo(): ^ misc_test.py:5:9: E225 missing whitespace around operator msgs=['Hello','World!!'] ^ misc_test.py:5:18: E231 missing whitespace after ',' msgs=['Hello','World!!'] ^ misc_test.py:9:10: W292 no newline at end of file foo() ^ 
  • About ʻautopep8`
  • It is a tool that even corrects automatically
  • Install with pip install autopep8 and want it to be automatically corrected as ʻautopep8 -i xxx.py` * If you specify .py, the contents of File will be corrected without asking questions (so be careful when executing) is)
Читайте также:  Css animation slide down

Источник

Добрый вечер, пытаюсь запустить парсер сайта, выдает ошибки, в чем проблема?

pro100chel

No_FaP, у меня ошибки не выдает. Возможно у тебя еще есть код кроме этого? Обычно такое бывает когда юзаешь 2 и 4 пробела в отступах одновременно.

Разберись с отступами или кадай весь код!

from bs4 import BeautifulSoup import requests def save(): with open('parse_info.txt', 'a') as file: file.write(f' -> Price: -> Link: \n') def parse(): URL = 'https://www.olx.kz/transport/legkovye-avtomobili/' HEADERS = < 'User-Agent': '&&&' >response = requests.get(URL, headers=HEADERS) soup = BeautifulSoup(response.content, 'html.parser') items = soup.findAll('div', class_='offer-wrapper') comps = [] for item in items: comps.append(< 'title': item.find('a', class_='marginright5 link linkWithHash detailsLink linkWithHashPromoted').get_text( strip=True), 'price': item.find('p', class_='price').get_text(strip=True), 'link': item.find('a', class_='marginright5 link linkWithHash detailsLink linkWithHashPromoted').get('href') >) global comp for comp in comps: print(f' -> Price: -> Link: ') save() parse()

Traceback (most recent call last):
File «C:\Users\User\Desktop\tester.py», line 33, in
parse()
File «C:\Users\User\Desktop\tester.py», line 23, in parse
‘title’: item.find(‘a’, class_=’marginright5 link linkWithHash detailsLink linkWithHashPromoted’).get_text(
AttributeError: ‘NoneType’ object has no attribute ‘get_text’
[Finished in 0.8s]

Источник

Русские Блоги

[Python + Pycharm] Есть волнистая линия в нижней части слова, когда подсказка в слове предлагается

При использовании IDEA в коде есть волнистая линия внизу слова, когда появляется подсказка в слове
Причина: функция проверки правописания слова указывает, что текущее правописание неверно,

Решение: переименуйте его в соответствии с номенклатурой горбов

Используйте свое собственное имя в качестве тега. Но обнаружил, что есть очень хорошее напоминание. Волны, я буду твоей сестрой.

Typo:In word ‘miyuehu’ less. (Ctrl+F1)

spellchecker inspection helps locate typos and misspelled in your code,comments and literals, and fix them in one click.

Нима, я не могу принять это. Спешите и найдите решение. , ,

Снимите опечатку правописания (отключите проверку правописания слов)

Нажмите «Применить», чтобы закрыть окно. Посмотрев на него, намек на волну действительно исчез. Хаха ~~~

Будь счастлив. молча. , , Прочитайте перевод этого предложения. , ,

spellchecker inspection helps locate typos and misspelled in your code,comments and literals, and fix them in one click.

Программа проверки орфографии экзамен может помочь найти Орфографическая ошибка с Орфографическая ошибка в вы из Код , Ноты с текст 、 а также ремонт Они в один раз щелчок 。

На данный момент эта функция очень хороша! ! ! Все имеет свою ценность в существовании. , , Мышление. , , Руки вверх. , ,

Да, что-то было обнаружено! ! ! Выберите слово и щелкните правой кнопкой мыши, чтобы лечь.

Изменить на . не обязательно.

Сохранить «miyuehu» в словарь . не означает сохранение в словарь. , , Решающий момент. При взгляде волны исчезли.

На данный момент волна окончательно разрешена, возможно, это и есть решение.

Как начинающий pyCharm, я должен сказать, что эта IDE действительно удобна для написания Python.
Однако из-за проблем со стилем кода я столкнулся с тем, что имя функции должно быть в нижнем регистре, что действительно раздражает. Поделитесь решением здесь.

File –>Settings–>Editor–>Inspections–>Python–>PEP 8 naming convention violation

В правом нижнем углу есть элемент управления списком игнорируемых ошибок, добавьте
N802
N803
N806

code sample message N801 class names should use CapWords convention N802 function name should be lowercase N803 argument name should be lowercase N804 first argument of a classmethod should be named 'cls' N805 first argument of a method should be named 'self' N806 variable in function should be lowercase N811 constant imported as non constant N812 lowercase imported as non lowercase N813 camelcase imported as lowercase N814 camelcase imported as constant

Источник

Оцените статью