Enable new checks for pylint core
moylop260 opened this issue ยท 14 comments
pylint core core has useful checks but they are disabled from OCA configuration files because we are only enabling new checks from pylint-odoo
e.g.
super-with-arguments - Consider using Python 3 style super() without arguments
Now, py3 doesn't require to define:
super(ClassName, self).method()
Only using
super().method()
So, IMHO it could be good idea enabled for new versions
I just cloned_everything and ran pre-commit-vauxoo overall projects in order to get the lints enabled filtered from my side but not from OCA
The result was the following checks:
bad-classmethod-argument
Class method _build_component_check_parent should have 'cls' as first argument
Class method _process_data_node should have 'cls' as first argument
Class method _process_record_node should have 'cls' as first argument
bad-docstring-quotes
Bad docstring quotes in method, expected """, given "
- e.g. https://github.com/OCA/account-payment/blob/d90f759340ecfe6c8eac8aeff720009f0557079f/account_payment_term_discount/models/account_move.py#L54
- e.g. https://github.com/OCA/odoo-pim/blob/d652a63310c7978a7a6f3f5c476e85199e1fecdf/attribute_set/models/attribute_attribute.py#L238
- e.g. https://github.com/OCA/l10n-romania/blob/05270ad795cb9484ef2131dc0c0ee9ed2c909ff3/l10n_ro_stock_picking_comment_template/models/stock_picking.py#L22
bad-except-order
Bad except clauses order (OSError is an ancestor class of PermissionError)
bad-indentation
Bad indentation. Found 36 spaces, expected 32
Bad indentation. Found 16 spaces, expected 12
bad-staticmethod-argument
Static method with 'self' as first argument
bare-except
No exception type(s) specified
chained-comparison
Simplify chained comparison between the operands
- e.g. https://github.com/OCA/server-tools/blob/8cf6b95cf7bd96fee45a9bf1b46d57f7cfc609be/excel_import_export/models/xlsx_export.py#L55
- e.g. https://github.com/OCA/l10n-france/blob/6746eb5bf0ba4a54e5ad53eb5d0c75cc8c29dbbf/l10n_fr_account_vat_return/models/res_company.py#L514
- e.g. https://github.com/OCA/vertical-association/blob/6dd224770addfc09383997fac356065ef4904361/membership_extension/models/res_partner.py#L160
condition-evals-to-constant
Boolean condition 'not 'service_line_ids' and 'folio_id' in vals' will always evaluate to 'not 'service_line_ids''
consider-iterating-dictionary
Consider iterating the dictionary directly instead of calling .keys()
- e.g. https://github.com/OCA/website-cms/blob/c7b7068df0f4541667c1205a520f03886d0dcc28/cms_form/models/cms_form_wizard.py#L69
- e.g. https://github.com/OCA/l10n-spain/blob/cd13dc2e6028fe5870a9e28651046940c779c08e/l10n_es_ticketbai_api_batuz/lroe/lroe_xml_schema.py#L194
- e.g. https://github.com/OCA/timesheet/blob/77c521ce7f0157a05cbfe8ef1b38b04b8be3b798/hr_timesheet_purchase_order/models/hr_timesheet_sheet.py#L82
consider-using-dict-comprehension
consider-using-enumerate
Consider using enumerate instead of iterating with range and len
- e.g. https://github.com/OCA/management-system/blob/512d77c2ada143a3aafe7911d5e9a82633b0cd43/mgmtsystem_audit/models/mgmtsystem_audit.py#L181
- e.g. https://github.com/OCA/account-financial-reporting/blob/71d2aeb5c79b8b7a82d1a0bcc1544c638908d507/partner_statement/report/activity_statement_xlsx.py#L107
- e.g. https://github.com/OCA/account-financial-reporting/blob/71d2aeb5c79b8b7a82d1a0bcc1544c638908d507/partner_statement/report/outstanting_statement_xlsx.py#L102
consider-using-from-import
Use 'from odoo import http' instead
Use 'from odoo import tools' instead
consider-using-generator
Consider using a generator instead 'tuple(provision_line.get(key) for key in merge_keys)'
Consider using a generator instead 'tuple(tuple(row.values()) for row in supplierinfo_group_vals)'
Consider using a generator instead 'tuple(row[0] for row in lock_cr.fetchall())'
consider-using-get
Consider using dict.get for getting values from a dict if a key is present or a default if not
consider-using-in
Consider merging these comparisons with "in" to 'rec in (rec.source_cmpcol_from_id, rec.source_cmpcol_to_id)'
Consider merging these comparisons with "in" to 'lroe_response_obj.state in (LROEOperationResponseState.BUILD_ERROR.value, LROEOperationResponseState.REQUEST_ERROR.value, LROEOperationResponseState.INCORRECT.value)'
Consider merging these comparisons with "in" to 'lroe_response_operation in (LROEOperationResponseState.BUILD_ERROR.value, LROEOperationResponseState.REQUEST_ERROR.value)'
consider-using-max-builtin
Consider using 'shipping_date = max(shipping_date, tomorrow)' instead of unnecessary if block
Consider using 'requested_date = max(requested_date, today)' instead of unnecessary if block
Consider using 'remaining_qty = max(remaining_qty, 0)' instead of unnecessary if block
consider-using-min-builtin
Consider using 'day = min(day, days_in_month)' instead of unnecessary if block
Consider using 'day = min(day, days_in_month)' instead of unnecessary if block
Consider using 'new_percentage = min(new_percentage, 100)' instead of unnecessary if block
consider-using-with
Consider using 'with' for resource-allocating operations
- e.g. https://github.com/OCA/edi/blob/87eea2d4e858b388e9b1cc5656511345bb8e9019/account_invoice_import_simple_pdf/wizard/account_invoice_import.py#L95
- e.g. https://github.com/OCA/edi/blob/87eea2d4e858b388e9b1cc5656511345bb8e9019/account_invoice_import_simple_pdf/wizard/account_invoice_import.py#L170
- e.g. https://github.com/OCA/bank-statement-import/blob/f89044d57b6883554158ad519285676f06c58cc2/account_statement_import_camt/models/account_statement_import.py#L29
deprecated-class
Using deprecated class Mapping of module collections
deprecated-method
Using deprecated method encodestring()
Using deprecated method warn()
Using deprecated method warn()
deprecated-module
Uses of a deprecated module 'bs4'
Uses of a deprecated module 'bs4'
Uses of a deprecated module 'xml.etree.cElementTree'
docstring-first-line-empty
First line empty in method docstring
- e.g. https://github.com/OCA/operating-unit/blob/813fdb50a8b8098b1b7f0e6fafd1c7033ec2041a/purchase_operating_unit/models/account_invoice.py#L13
- e.g. https://github.com/OCA/operating-unit/blob/813fdb50a8b8098b1b7f0e6fafd1c7033ec2041a/purchase_operating_unit/models/account_invoice.py#L26
- e.g. https://github.com/OCA/account-payment/blob/d90f759340ecfe6c8eac8aeff720009f0557079f/partner_aging/wizard/res_partner_aging_customer.py#L363
duplicate-key
Duplicate key 'zpl2.ARG_HEIGHT' in dictionary
duplicate-string-formatting-argument
Duplicate string formatting argument 'age_date', consider passing as named argument
Duplicate string formatting argument 'age_date', consider passing as named argument
Duplicate string formatting argument 'rfq', consider passing as named argument
empty-docstring
Empty method docstring
- e.g. https://github.com/OCA/l10n-switzerland/blob/de41257d8daeb4920ca4ae8f948b301da1f7b081/ebill_paynet/models/paynet_service.py#L110
- e.g. https://github.com/OCA/l10n-switzerland/blob/de41257d8daeb4920ca4ae8f948b301da1f7b081/ebill_paynet/models/paynet_service.py#L125
- e.g. https://github.com/OCA/l10n-switzerland/blob/de41257d8daeb4920ca4ae8f948b301da1f7b081/ebill_paynet/models/account_invoice.py#L111
exec-used
expression-not-assigned
Expression "[result[0].update({x: False}) for x in fields if x not in real_fields]" is assigned to nothing
Expression "self._context.get('tz') or self.env.user.partner_id.tz or 'UTC'" is assigned to nothing
Expression "self._context.get('tz') or self.env.user.partner_id.tz or 'UTC'" is assigned to nothing
format-string-without-interpolation
Using formatting for a string that does not have any interpolated variables
function-redefined
class already defined line 8
class already defined line 11
class already defined line 4
global-statement
Using the global statement
- e.g. https://github.com/OCA/queue/blob/51df45ad842090c26302d376aa5b5a6dfc8f8dc7/queue_job/jobrunner/__init__.py#L94
- e.g. https://github.com/OCA/queue/blob/51df45ad842090c26302d376aa5b5a6dfc8f8dc7/queue_job/jobrunner/__init__.py#L149
- e.g. https://github.com/OCA/server-tools/blob/8cf6b95cf7bd96fee45a9bf1b46d57f7cfc609be/sql_request_abstract/sql_db.py#L18
global-variable-not-assigned
Using global for 'ENDPOINT_ROUTE_CONSUMER_MODELS' but no assignment is done
Using global for 'qty_assigned' but no assignment is done
Using global for '_extender_functions' but no assignment is done
global-variable-undefined
Global variable 'qty_assigned' undefined at the module level
implicit-str-concat
Implicit string concatenation found in tuple
Implicit string concatenation found in tuple
Implicit string concatenation found in assignment
import-outside-toplevel
Import outside toplevel (unidecode.unidecode)
Import outside toplevel (requests)
Import outside toplevel (subprocess)
invalid-character-zero-width-space
Invalid unescaped character zero-width-space, use "\u200B" instead.
invalid-metaclass
Invalid metaclass 'MetaDatamodel' used
Invalid metaclass 'MetaModelSerializer' used
Invalid metaclass 'RestControllerType' used
invalid-name
Variable name "w" doesn't conform to '[a-z_][a-z0-9_]{1,59}$' pattern
Variable name "r" doesn't conform to '[a-z_][a-z0-9_]{1,59}$' pattern
Variable name "s" doesn't conform to '[a-z_][a-z0-9_]{1,59}$' pattern
invalid-sequence-index
Sequence index is not an int, slice, or instance with __index__
invalid-unary-operand-type
bad operand type for unary -: str
isinstance-second-argument-not-valid-type
Second argument of isinstance is not a type
logging-format-interpolation
Use lazy % formatting in logging functions
- e.g. https://github.com/OCA/edi/blob/87eea2d4e858b388e9b1cc5656511345bb8e9019/base_ebill_payment_contract/models/res_partner.py#L24
- e.g. https://github.com/OCA/server-ux/blob/c5750fe58f988e76d2ea4e5c3321588503a135b3/base_tier_validation_server_action/models/tier_definition.py#L53
- e.g. https://github.com/OCA/server-ux/blob/c5750fe58f988e76d2ea4e5c3321588503a135b3/base_tier_validation_server_action/models/tier_definition.py#L65
logging-fstring-interpolation
Use lazy % formatting in logging functions
logging-not-lazy
Use lazy % formatting in logging functions
- e.g. https://github.com/OCA/operating-unit/blob/813fdb50a8b8098b1b7f0e6fafd1c7033ec2041a/product_operating_unit/models/product_template.py#L64
- e.g. https://github.com/OCA/delivery-carrier/blob/ca33f465c659d87cf98c3b097f8ef1c77ade2ce0/delivery_postlogistics/postlogistics/web_service.py#L517
- e.g. https://github.com/OCA/delivery-carrier/blob/ca33f465c659d87cf98c3b097f8ef1c77ade2ce0/base_delivery_carrier_label/models/stock_move_line.py#L35
logging-too-many-args
Too many arguments for logging format string
- e.g. https://github.com/OCA/edi/blob/87eea2d4e858b388e9b1cc5656511345bb8e9019/edi_oca/models/edi_backend.py#L124
- e.g. https://github.com/OCA/sale-workflow/blob/740eab52bab3ab7994b745dcbdbfdbd5f6178e71/sale_delivery_date/models/sale_order_line.py#L119
- e.g. https://github.com/OCA/stock-logistics-warehouse/blob/b6186854dd3db5872f102f390360356c6d2b7ae0/stock_vertical_lift_kardex/models/stock_location.py#L93
method-hidden
An attribute defined in json.decoder line 319 hides this method
missing-format-attribute
Missing format attribute 'id' in format specifier '0.id'
modified-iterating-dict
Iterated dict 'taxes_keys' is being modified inside for loop body, iterate through a copy of it instead.
no-else-break
Unnecessary "else" after "break", remove the "else" and de-indent the code inside it
Unnecessary "elif" after "break", remove the leading "el" from "elif"
Unnecessary "else" after "break", remove the "else" and de-indent the code inside it
no-else-continue
Unnecessary "elif" after "continue", remove the leading "el" from "elif"
Unnecessary "elif" after "continue", remove the leading "el" from "elif"
Unnecessary "else" after "continue", remove the "else" and de-indent the code inside it
no-else-raise
Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it
- e.g. https://github.com/OCA/operating-unit/blob/813fdb50a8b8098b1b7f0e6fafd1c7033ec2041a/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py#L39
- e.g. https://github.com/OCA/edi/blob/87eea2d4e858b388e9b1cc5656511345bb8e9019/account_invoice_import_simple_pdf/models/account_invoice_import_simple_pdf_fields.py#L131
- e.g. https://github.com/OCA/edi/blob/87eea2d4e858b388e9b1cc5656511345bb8e9019/account_invoice_import_simple_pdf/models/account_invoice_import_simple_pdf_fields.py#L163
no-else-return
Unnecessary "else" after "return", remove the "else" and de-indent the code inside it
- e.g. https://github.com/OCA/operating-unit/blob/813fdb50a8b8098b1b7f0e6fafd1c7033ec2041a/product_operating_unit/models/product_template.py#L66
- e.g. https://github.com/OCA/iot/blob/7bbc24f516663d5a2fc25edeeaef32099f3b9a84/iot_input_oca/models/iot_device.py#L55
- e.g. https://github.com/OCA/connector-ecommerce/blob/05046744738f13bf6ad8c12016b5f0fe1002e4b3/connector_ecommerce/models/sale.py#L204
no-self-argument
Method should have "self" as first argument
- e.g. https://github.com/OCA/server-tools/blob/8cf6b95cf7bd96fee45a9bf1b46d57f7cfc609be/upgrade_analysis/odoo_patch/addons/mrp/__init__.py#L10
- e.g. https://github.com/OCA/server-tools/blob/8cf6b95cf7bd96fee45a9bf1b46d57f7cfc609be/upgrade_analysis/odoo_patch/addons/point_of_sale/__init__.py#L12
- e.g. https://github.com/OCA/server-tools/blob/8cf6b95cf7bd96fee45a9bf1b46d57f7cfc609be/upgrade_analysis/odoo_patch/addons/stock/__init__.py#L10
not-an-iterable
Non-iterable value weekends is used in an iterating context
Non-iterable value self.stock_move_location_line_ids is used in an iterating context
Non-iterable value self.stock_move_location_line_ids is used in an iterating context
not-callable
state_method is not callable
state_method is not callable
active is not callable
possibly-unused-variable
Possibly unused variable 'message'
raising-bad-type
Raising NoneType while only classes or instances are allowed
- e.g. https://github.com/OCA/edi/blob/87eea2d4e858b388e9b1cc5656511345bb8e9019/base_business_document_import/models/business_document_import.py#L346
- e.g. https://github.com/OCA/edi/blob/87eea2d4e858b388e9b1cc5656511345bb8e9019/base_business_document_import/models/business_document_import.py#L459
- e.g. https://github.com/OCA/edi/blob/87eea2d4e858b388e9b1cc5656511345bb8e9019/base_business_document_import/models/business_document_import.py#L603
redefined-argument-from-local
Redefining argument with the local name 'node'
Redefining argument with the local name 'reason'
Redefining argument with the local name 'domain'
redefined-builtin
Redefining built-in 'copyright'
Redefining built-in 'type'
Redefining built-in 'type'
redefined-outer-name
Redefining name 'fields' from outer scope (line 7)
Redefining name 'fields' from outer scope (line 5)
Redefining name 'fields' from outer scope (line 5)
redundant-u-string-prefix
The u prefix for strings is no longer necessary in Python >=3.0
- e.g. https://github.com/OCA/account-financial-reporting/blob/71d2aeb5c79b8b7a82d1a0bcc1544c638908d507/account_financial_report/report/aged_partner_balance_xlsx.py#L42
- e.g. https://github.com/OCA/account-financial-reporting/blob/71d2aeb5c79b8b7a82d1a0bcc1544c638908d507/account_financial_report/report/aged_partner_balance_xlsx.py#L50
- e.g. https://github.com/OCA/account-financial-reporting/blob/71d2aeb5c79b8b7a82d1a0bcc1544c638908d507/account_financial_report/report/aged_partner_balance_xlsx.py#L58
relative-beyond-top-level
Attempted relative import beyond top-level package
- e.g. https://github.com/OCA/social/blob/e61b55a2c424ab7a50aa13f3e2378c247c68e4c4/mail_tracking_mailgun/controllers/main.py#L15
- e.g. https://github.com/OCA/social/blob/e61b55a2c424ab7a50aa13f3e2378c247c68e4c4/mail_tracking_mailgun/controllers/main.py#L16
- e.g. https://github.com/OCA/l10n-chile/blob/ccb2074f2ee101375842092a2a0d1a788e62d7bd/l10n_cl_etd_xerox/models/etd_mixin.py#L6
self-assigning-variable
Assigning the same variable 'count' to itself
Assigning the same variable 'country_code' to itself
Assigning the same variable 'qty' to itself
simplifiable-condition
Boolean condition 'safe_eval(self.rule_domain) or []' may be simplified to 'safe_eval(self.rule_domain)'
simplifiable-if-expression
The if expression can be replaced with 'test'
The if expression can be replaced with 'test'
The if expression can be replaced with 'bool(test)'
simplifiable-if-statement
The if statement can be replaced with 'var = bool(test)'
The if statement can be replaced with 'var = bool(test)'
The if statement can be replaced with 'return bool(test)'
simplify-boolean-expression
Boolean expression may be simplified to product.name
Boolean expression may be simplified to asset.name
Boolean expression may be simplified to False
single-string-used-for-slots
Class __slots__ should be a non-string iterable
subprocess-popen-preexec-fn
Using preexec_fn keyword which may be unsafe in the presence of threads
super-init-not-called
__init__ method from base class 'Exception' is not called
- e.g. https://github.com/OCA/l10n-spain/blob/cd13dc2e6028fe5870a9e28651046940c779c08e/l10n_es_ticketbai_api_batuz/lroe/lroe_xml_schema.py#L36
- e.g. https://github.com/OCA/l10n-spain/blob/cd13dc2e6028fe5870a9e28651046940c779c08e/l10n_es_ticketbai_api/ticketbai/xml_schema.py#L20
- e.g. https://github.com/OCA/l10n-spain/blob/cd13dc2e6028fe5870a9e28651046940c779c08e/l10n_es_facturae/wizard/create_facturae.py#L17
super-with-arguments
Consider using Python 3 style super() without arguments
- e.g. https://github.com/OCA/operating-unit/blob/813fdb50a8b8098b1b7f0e6fafd1c7033ec2041a/stock_operating_unit/model/stock_picking.py#L20
- e.g. https://github.com/OCA/operating-unit/blob/813fdb50a8b8098b1b7f0e6fafd1c7033ec2041a/operating_unit/models/operating_unit.py#L69
- e.g. https://github.com/OCA/operating-unit/blob/813fdb50a8b8098b1b7f0e6fafd1c7033ec2041a/operating_unit/models/operating_unit.py#L76
superfluous-parens
Unnecessary parens after 'raise' keyword
Unnecessary parens after 'raise' keyword
Unnecessary parens after 'not' keyword
too-complex
'get_value_from_list' is too complex. The McCabe rating is 17
'_direct_match' is too complex. The McCabe rating is 16
'pre_process_parsed_inv' is too complex. The McCabe rating is 16
too-many-nested-blocks
Too many nested blocks (6/5)
- e.g. https://github.com/OCA/purchase-reporting/blob/674560128ed7d06db8ec0a917011ffa81c4cea79/purchase_backorder/models/purchase.py#L112
- e.g. https://github.com/OCA/purchase-reporting/blob/674560128ed7d06db8ec0a917011ffa81c4cea79/purchase_backorder/models/purchase.py#L130
- e.g. https://github.com/OCA/l10n-romania/blob/05270ad795cb9484ef2131dc0c0ee9ed2c909ff3/l10n_ro_fiscal_validation/models/res_partner.py#L45
too-many-return-statements
Too many return statements (7/6)
Too many return statements (9/6)
Too many return statements (9/6)
trailing-comma-tuple
trailing-newlines
Trailing newlines
- e.g. https://github.com/OCA/vertical-abbey/blob/bb30f10f806bac93345de627acd526e50e5a23e7/stay_report_py3o/__init__.py#L2
- e.g. https://github.com/OCA/currency/blob/3193f2b21e0b6cfae7d3e0d4369f8d13999ae18c/account_cryptocurrency/__init__.py#L2
- e.g. https://github.com/OCA/l10n-croatia/blob/24287b56f964b5b420bda6f240e3c3952091a580/l10n_hr_bank/__init__.py#L4
undefined-loop-variable
Using possibly undefined loop variable 'map_line'
Using possibly undefined loop variable 'map_line'
Using possibly undefined loop variable 'record'
undefined-variable
Undefined variable 'long'
Undefined variable 'basestring'
Undefined variable 'long'
unidiomatic-typecheck
Use isinstance() rather than type() for a typecheck.
- e.g. https://github.com/OCA/delivery-carrier/blob/ca33f465c659d87cf98c3b097f8ef1c77ade2ce0/delivery_correos_express/models/correos_express_request.py#L95
- e.g. https://github.com/OCA/delivery-carrier/blob/ca33f465c659d87cf98c3b097f8ef1c77ade2ce0/delivery_correos_express/models/correos_express_request.py#L99
- e.g. https://github.com/OCA/delivery-carrier/blob/ca33f465c659d87cf98c3b097f8ef1c77ade2ce0/delivery_correos_express/models/correos_express_request.py#L103
unnecessary-comprehension
Unnecessary use of a comprehension, use set(self.subkpi_ids) instead.
Unnecessary use of a comprehension, use dict(self.request.files.items()) instead.
Unnecessary use of a comprehension, use list(sorted(withholding_tax_template.keys())) instead.
unnecessary-lambda
Lambda may not be necessary
- e.g. https://github.com/OCA/account-payment/blob/d90f759340ecfe6c8eac8aeff720009f0557079f/partner_aging/wizard/res_partner_aging_date.py#L14
- e.g. https://github.com/OCA/edi/blob/87eea2d4e858b388e9b1cc5656511345bb8e9019/edi_oca/models/edi_backend.py#L121
- e.g. https://github.com/OCA/bank-statement-import/blob/f89044d57b6883554158ad519285676f06c58cc2/account_statement_import_paypal/models/account_statement_import_paypal_parser.py#L59
unnecessary-pass
Unnecessary pass statement
- e.g. https://github.com/OCA/website-cms/blob/c7b7068df0f4541667c1205a520f03886d0dcc28/cms_form/models/cms_form.py#L141
- e.g. https://github.com/OCA/website-cms/blob/c7b7068df0f4541667c1205a520f03886d0dcc28/cms_form/models/cms_form.py#L145
- e.g. https://github.com/OCA/connector-infor/blob/6f1643965ae7ba5e04a8be8cbcf27b4b274129ba/connector_infor_account_move/models/account_move.py#L144
unneeded-not
Consider changing "not self._name == 'wiz.stock.barcodes.read.inventory'" to "self._name != 'wiz.stock.barcodes.read.inventory'"
unsupported-assignment-operation
'self.current_transaction' does not support item assignment
- e.g. https://github.com/OCA/l10n-poland/blob/5f711929623cbadc281cfa089f314619cb61b318/account_bank_statement_import_mt940_pl_raiffeisen/mt940.py#L79
- e.g. https://github.com/OCA/l10n-poland/blob/5f711929623cbadc281cfa089f314619cb61b318/account_bank_statement_import_mt940_pl_raiffeisen/mt940.py#L82
- e.g. https://github.com/OCA/l10n-poland/blob/5f711929623cbadc281cfa089f314619cb61b318/account_bank_statement_import_mt940_pl_raiffeisen/mt940.py#L83
unsupported-membership-test
Value 'self.value_ids' doesn't support membership test
unused-import
Unused job imported from odoo.addons.queue_job.job
- e.g. https://github.com/OCA/l10n-spain/blob/cd13dc2e6028fe5870a9e28651046940c779c08e/l10n_es_aeat_sii_oca/models/account_move.py#L31
- e.g. https://github.com/OCA/l10n-spain/blob/cd13dc2e6028fe5870a9e28651046940c779c08e/l10n_es_ticketbai_batuz/models/lroe_operation.py#L24
- e.g. https://github.com/OCA/server-ux/blob/c5750fe58f988e76d2ea4e5c3321588503a135b3/document_quick_access_folder_auto_classification/models/document_quick_access_rule.py#L8
unused-variable
Unused variable 'field'
Unused variable 'mode'
Unused variable 'ml_domain'
use-a-generator
Use a generator instead 'any(x.get('form') for x in config.values())'
Use a generator instead 'any(kw.get(k) for k in match_attrs)'
Use a generator instead 'all(model._fields[f].store for f in field_names)'
use-dict-literal
Consider using {} instead of dict()
- e.g. https://github.com/OCA/edi/blob/87eea2d4e858b388e9b1cc5656511345bb8e9019/account_invoice_ubl/models/account_move.py#L94
- e.g. https://github.com/OCA/delivery-carrier/blob/ca33f465c659d87cf98c3b097f8ef1c77ade2ce0/delivery_carrier_label_batch/zpl_utils.py#L7
- e.g. https://github.com/OCA/delivery-carrier/blob/ca33f465c659d87cf98c3b097f8ef1c77ade2ce0/delivery_carrier_label_batch/zpl_utils.py#L8
use-implicit-booleaness-not-len
Do not use
len(SEQUENCE)without comparison to determine if a sequence is empty
- e.g. https://github.com/OCA/account-payment/blob/d90f759340ecfe6c8eac8aeff720009f0557079f/account_payment_return_import/wizard/base_parser.py#L42
- e.g. https://github.com/OCA/edi/blob/87eea2d4e858b388e9b1cc5656511345bb8e9019/sale_order_import/wizard/sale_order_import.py#L89
- e.g. https://github.com/OCA/edi/blob/87eea2d4e858b388e9b1cc5656511345bb8e9019/pdf_helper/utils.py#L36
use-list-literal
Consider using [] instead of list()
- e.g. https://github.com/OCA/delivery-carrier/blob/ca33f465c659d87cf98c3b097f8ef1c77ade2ce0/delivery_carrier_label_batch/zpl_utils.py#L21
- e.g. https://github.com/OCA/l10n-spain/blob/cd13dc2e6028fe5870a9e28651046940c779c08e/l10n_es_ticketbai_batuz/models/account_move.py#L323
- e.g. https://github.com/OCA/l10n-spain/blob/cd13dc2e6028fe5870a9e28651046940c779c08e/l10n_es_ticketbai_batuz/models/account_move.py#L325
use-sequence-for-iteration
Use a sequence type when iterating over values
- e.g. https://github.com/OCA/bank-statement-import/blob/f89044d57b6883554158ad519285676f06c58cc2/account_statement_import_online_ponto/models/online_bank_statement_provider_ponto.py#L228
- e.g. https://github.com/OCA/wms/blob/62d1467b8a9f76219ebb01be22b832a80c43e841/shopfloor_base/models/shopfloor_app.py#L235
- e.g. https://github.com/OCA/event/blob/e2948d82b59fe793eb22bd4cce84607fe0823f4d/partner_event/models/event_registration.py#L40
use-symbolic-message-instead
'W7950' is cryptic: use '# pylint: disable=odoo-addons-relative-import' instead
'E8102' is cryptic: use '# pylint: disable=invalid-commit' instead
'E8102' is cryptic: use '# pylint: disable=invalid-commit' instead
useless-object-inheritance
Class 'BaseParser' inherits from object, can be safely removed from bases in python3
Class 'CamtParser' inherits from object, can be safely removed from bases in python3
Class 'PainParser' inherits from object, can be safely removed from bases in python3
useless-return
Useless return at end of function or method
- e.g. https://github.com/OCA/edi/blob/87eea2d4e858b388e9b1cc5656511345bb8e9019/account_einvoice_generate/models/account_move.py#L11
- e.g. https://github.com/OCA/edi/blob/87eea2d4e858b388e9b1cc5656511345bb8e9019/base_ubl/models/ubl.py#L112
- e.g. https://github.com/OCA/edi/blob/87eea2d4e858b388e9b1cc5656511345bb8e9019/account_invoice_facturx/models/account_move.py#L159
useless-super-delegation
Useless super delegation in method 'write'
Useless super delegation in method 'mapped'
Useless super delegation in method '__init__'
using-constant-test
Using a conditional statement with a constant value
- e.g. https://github.com/OCA/delivery-carrier/blob/ca33f465c659d87cf98c3b097f8ef1c77ade2ce0/delivery_roulier/models/delivery_carrier.py#L30
- e.g. https://github.com/OCA/l10n-brazil/blob/24a84289c3b149b2676db5e687e5198d5ed4dc39/spec_driven_model/models/spec_view.py#L186
- e.g. https://github.com/OCA/l10n-brazil/blob/24a84289c3b149b2676db5e687e5198d5ed4dc39/spec_driven_model/models/spec_export.py#L211
wildcard-import
Wildcard import marshmallow.fields
Check the following example detected:
using-constant-test
Using a conditional statement with a constant value
The code has:
def _is_roulier(self):
self.ensure_one()
available_carrier_actions = roulier.get_carriers_action_available() or {}
return "get_label" in available_carrier_actions.get(self.delivery_type, [])
def cancel_shipment(self, pickings):
if self._is_roulier:
pickings._cancel_shipment()
else:
return super().cancel_shipment(pickings)
Notice the if self._is_roulier:
it will be True all the time since it is a method definition
It should be
- if self._is_roulier:
+ if self._is_roulier():
So, this module will not working as expected but it could be detected from pylint checks
BTW This is a code 3 years old
Check the following case:
logging-format-interpolation
Use lazy % formatting in logging functions
- e.g. https://github.com/OCA/edi/blob/87eea2d4e858b388e9b1cc5656511345bb8e9019/base_ebill_payment_contract/models/res_partner.py#L24
- e.g. https://github.com/OCA/server-ux/blob/c5750fe58f988e76d2ea4e5c3321588503a135b3/base_tier_validation_server_action/models/tier_definition.py#L53
- e.g. https://github.com/OCA/server-ux/blob/c5750fe58f988e76d2ea4e5c3321588503a135b3/base_tier_validation_server_action/models/tier_definition.py#L65
It is using str.format for a logger
It is better evaluating the string from the logger method itself it save processor if the logger is disabled and avoid raising errors if the format is wrong to show a logger
- _logger.error("Paynet contract for {} on {} not found".format(self.name, transmit_method.name))
+ _logger.error("Paynet contract for %s on %s not found, self.name, transmit_method.name)
Notice the following
logging-too-many-args
Too many arguments for logging format string
- e.g. https://github.com/OCA/edi/blob/87eea2d4e858b388e9b1cc5656511345bb8e9019/edi_oca/models/edi_backend.py#L124
- e.g. https://github.com/OCA/sale-workflow/blob/740eab52bab3ab7994b745dcbdbfdbd5f6178e71/sale_delivery_date/models/sale_order_line.py#L119
- e.g. https://github.com/OCA/stock-logistics-warehouse/blob/b6186854dd3db5872f102f390360356c6d2b7ae0/stock_vertical_lift_kardex/models/stock_location.py#L93
This logger is wrong:
- _logger.debug("using component", component._name)
+ _logger.debug("using component %s", component._name)
Check the following
possibly-unused-variable
Possibly unused variable 'message'
- message = "O Documento Fiscal %s foi exportado." % inv.fiscal_number
+ self.message = "O Documento Fiscal %s foi exportado." % inv.fiscal_number # or something similar
Check the following case:
Assigning the same variable 'country_code' to itself
country_code = country_code
Check the following case:
unnecessary-comprehension
Unnecessary use of a comprehension, use set(self.subkpi_ids) instead.
- new_subkpis = {subkpi for subkpi in self.subkpi_ids}
+ new_subkpis = set(self.subkpi_ids)
Why is better using a lazy logger?
Notice the following case:
_logger.info("Wrong logger %s" % ("hello1", "hello2"))
Result:
TypeError: not all arguments converted during string formatting
But using:
_logger.info("Wrong logger %s", "hello1", "hello2")
It will not raises error
Note: odoo _logger is not compatible with "{}".format _logger.info('Hello, {}', 'world')
File "/usr/lib/python3.8/logging/init.py", line 373, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
I agree we should add those checks.
What file/section should be it added?
Could you take advantage to discuss all these lints during OCA days and make a PR to enable them?
I won't be there this year, sorry. Only odoo experience.
@moylop260 are you at OCA days? I've not seen you yet.
Hi my friends
This year we won't travel to Belgium
There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.