diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index caf374cf..fa0a17bd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: ] - repo: https://github.com/PyCQA/pylint - rev: v2.17.1 + rev: v2.17.7 hooks: - id: pylint name: pylint @@ -34,7 +34,7 @@ repos: ] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.4.1 + rev: v1.6.1 hooks: - id: mypy args: [] diff --git a/.pylintrc b/.pylintrc index 41a6c512..89ad2322 100644 --- a/.pylintrc +++ b/.pylintrc @@ -5,6 +5,10 @@ # only in one or another interpreter, leading to false positives when analysed. analyse-fallback-blocks=no +# Clear in-memory caches upon conclusion of linting. Useful if running pylint +# in a server-like mode. +clear-cache-post-run=no + # Load and enable all available extensions. Use --list-extensions to see a list # all available extensions. #enable-all-extensions= @@ -35,7 +39,7 @@ extension-pkg-whitelist= fail-on= # Specify a score threshold under which the program will exit with error. -fail-under=10 +fail-under=10.0 # Interpret the stdin as a python script, whose filename needs to be passed as # the module_or_package argument. @@ -46,8 +50,8 @@ ignore=CVS # Add files or directories matching the regular expressions patterns to the # ignore-list. The regex matches against paths and can be in Posix or Windows -# format. Because '\' represents the directory delimiter on Windows systems, it -# can't be used as an escape character. +# format. Because '\\' represents the directory delimiter on Windows systems, +# it can't be used as an escape character. ignore-paths=tests,docs,examples,^mindee/product/fr/carte_grise/.*$ # Files or directories matching the regular expression patterns are skipped. @@ -68,7 +72,7 @@ ignored-modules= # Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the # number of processors available to use, and will cap the count on Windows to # avoid hangs. -jobs=1 +jobs=2 # Control the amount of potential inferred values when inferring a single # object. This can help the performance when dealing with large functions or @@ -84,11 +88,17 @@ persistent=yes # Minimum Python version to use for version dependent checks. Will default to # the version used to run pylint. -py-version=3.8 +#py-version=3.8 # Discover python modules and packages in the file system subtree. recursive=no +# Add paths to the list of the source roots. Supports globbing patterns. The +# source root is an absolute path or a path relative to the current working +# directory used to determine a package namespace for modules located under the +# source root. +source-roots= + # When enabled, pylint would attempt to guess common misconfiguration and emit # user-friendly hints instead of false-positive error messages. suggestion-mode=yes @@ -101,269 +111,244 @@ unsafe-load-any-extension=no #verbose= -[REPORTS] - -# Python expression which should return a score less than or equal to 10. You -# have access to the variables 'fatal', 'error', 'warning', 'refactor', -# 'convention', and 'info' which contain the number of messages in each -# category, as well as 'statement' which is the total number of statements -# analyzed. This score is used by the global evaluation report (RP0004). -evaluation=max(0, 0 if fatal else 10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)) +[BASIC] -# Template used to display messages. This is a python new-style format string -# used to format the message information. See doc for all details. -msg-template= +# Naming style matching correct argument names. +argument-naming-style=snake_case -# Set the output format. Available formats are text, parseable, colorized, json -# and msvs (visual studio). You can also give a reporter class, e.g. -# mypackage.mymodule.MyReporterClass. -#output-format= +# Regular expression matching correct argument names. Overrides argument- +# naming-style. If left empty, argument names will be checked with the set +# naming style. +#argument-rgx= -# Tells whether to display a full report or only the messages. -reports=no +# Naming style matching correct attribute names. +attr-naming-style=snake_case -# Activate the evaluation score. -score=yes +# Regular expression matching correct attribute names. Overrides attr-naming- +# style. If left empty, attribute names will be checked with the set naming +# style. +attr-rgx=[a-z_][a-z0-9_]{1,40}$ +# Bad variable names which should always be refused, separated by a comma. +bad-names=foo, + bar, + baz, + toto, + tutu, + tata -[MESSAGES CONTROL] +# Bad variable names regexes, separated by a comma. If names match any regex, +# they will always be refused +bad-names-rgxs= -# Only show warnings with the listed confidence levels. Leave empty to show -# all. Valid levels: HIGH, CONTROL_FLOW, INFERENCE, INFERENCE_FAILURE, -# UNDEFINED. -confidence=HIGH, - CONTROL_FLOW, - INFERENCE, - INFERENCE_FAILURE, - UNDEFINED +# Naming style matching correct class attribute names. +class-attribute-naming-style=any -# Disable the message, report, category or checker with the given id(s). You -# can either give multiple identifiers separated by comma (,) or put this -# option multiple times (only on the command line, not in the configuration -# file where it should appear only once). You can also use "--disable=all" to -# disable everything first and then re-enable specific checks. For example, if -# you want to run only the similarities checker, you can use "--disable=all -# --enable=similarities". If you want to run only the classes checker, but have -# no Warning level messages displayed, use "--disable=all --enable=classes -# --disable=W". -disable=too-few-public-methods, - missing-module-docstring, - too-many-instance-attributes, - too-many-arguments, - duplicate-code, - consider-using-join, +# Regular expression matching correct class attribute names. Overrides class- +# attribute-naming-style. If left empty, class attribute names will be checked +# with the set naming style. +#class-attribute-rgx= -# Enable the message, report, category or checker with the given id(s). You can -# either give multiple identifier separated by comma (,) or put this option -# multiple time (only on the command line, not in the configuration file where -# it should appear only once). See also the "--disable" option for examples. -enable=c-extension-no-member +# Naming style matching correct class constant names. +class-const-naming-style=UPPER_CASE +# Regular expression matching correct class constant names. Overrides class- +# const-naming-style. If left empty, class constant names will be checked with +# the set naming style. +#class-const-rgx= -[SIMILARITIES] +# Naming style matching correct class names. +class-naming-style=PascalCase -# Comments are removed from the similarity computation -ignore-comments=yes +# Regular expression matching correct class names. Overrides class-naming- +# style. If left empty, class names will be checked with the set naming style. +#class-rgx= -# Docstrings are removed from the similarity computation -ignore-docstrings=yes +# Naming style matching correct constant names. +const-naming-style=UPPER_CASE -# Imports are removed from the similarity computation -ignore-imports=yes +# Regular expression matching correct constant names. Overrides const-naming- +# style. If left empty, constant names will be checked with the set naming +# style. +#const-rgx= -# Signatures are removed from the similarity computation -ignore-signatures=yes +# Minimum line length for functions/classes that require docstrings, shorter +# ones are exempt. +docstring-min-length=-1 -# Minimum lines number of a similarity. -min-similarity-lines=4 +# Naming style matching correct function names. +function-naming-style=snake_case +# Regular expression matching correct function names. Overrides function- +# naming-style. If left empty, function names will be checked with the set +# naming style. +#function-rgx= -[TYPECHECK] +# Good variable names which should always be accepted, separated by a comma. +good-names=i, + j, + k, + ex, + Run, + _ -# List of decorators that produce context managers, such as -# contextlib.contextmanager. Add to this list to register other decorators that -# produce valid context managers. -contextmanager-decorators=contextlib.contextmanager +# Good variable names regexes, separated by a comma. If names match any regex, +# they will always be accepted +good-names-rgxs= -# List of members which are set dynamically and missed by pylint inference -# system, and so shouldn't trigger E1101 when accessed. Python regular -# expressions are accepted. -generated-members= +# Include a hint for the correct naming format with invalid-name. +include-naming-hint=no -# Tells whether to warn about missing members when the owner of the attribute -# is inferred to be None. -ignore-none=yes +# Naming style matching correct inline iteration names. +inlinevar-naming-style=any -# This flag controls whether pylint should warn about no-member and similar -# checks whenever an opaque object is returned when inferring. The inference -# can return multiple potential results while evaluating a Python object, but -# some branches might not be evaluated, which results in partial inference. In -# that case, it might be useful to still emit no-member and other checks for -# the rest of the inferred objects. -ignore-on-opaque-inference=yes +# Regular expression matching correct inline iteration names. Overrides +# inlinevar-naming-style. If left empty, inline iteration names will be checked +# with the set naming style. +#inlinevar-rgx= -# List of symbolic message names to ignore for Mixin members. -ignored-checks-for-mixins=no-member, - not-async-context-manager, - not-context-manager, - attribute-defined-outside-init +# Naming style matching correct method names. +method-naming-style=snake_case -# List of class names for which member attributes should not be checked (useful -# for classes with dynamically set attributes). This supports the use of -# qualified names. -ignored-classes=optparse.Values,thread._local,_thread._local,argparse.Namespace +# Regular expression matching correct method names. Overrides method-naming- +# style. If left empty, method names will be checked with the set naming style. +#method-rgx= -# Show a hint with possible names when a member name was not found. The aspect -# of finding the hint is based on edit distance. -missing-member-hint=yes +# Naming style matching correct module names. +module-naming-style=snake_case -# The minimum edit distance a name should have in order to be considered a -# similar match for a missing member name. -missing-member-hint-distance=1 +# Regular expression matching correct module names. Overrides module-naming- +# style. If left empty, module names will be checked with the set naming style. +#module-rgx= -# The total number of similar names that should be taken in consideration when -# showing a hint for a missing member. -missing-member-max-choices=1 +# Colon-delimited sets of names that determine each other's naming style when +# the name regexes allow several styles. +name-group= -# Regex pattern to define which classes are considered mixins. -mixin-class-rgx=.*[Mm]ixin +# Regular expression which should only match function or class names that do +# not require a docstring. +no-docstring-rgx=^_ -# List of decorators that change the signature of a decorated function. -signature-mutators= +# List of decorators that produce properties, such as abc.abstractproperty. Add +# to this list to register other decorators that produce valid properties. +# These decorators are taken in consideration only for invalid-name. +property-classes=abc.abstractproperty +# Regular expression matching correct type alias names. If left empty, type +# alias names will be checked with the set naming style. +#typealias-rgx= -[FORMAT] +# Regular expression matching correct type variable names. If left empty, type +# variable names will be checked with the set naming style. +#typevar-rgx= -# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. -expected-line-ending-format= +# Naming style matching correct variable names. +variable-naming-style=snake_case -# Regexp for a line that is allowed to be longer than the limit. -ignore-long-lines=^\s*(# )??$ +# Regular expression matching correct variable names. Overrides variable- +# naming-style. If left empty, variable names will be checked with the set +# naming style. +#variable-rgx= -# Number of spaces of indent required inside a hanging or continued line. -indent-after-paren=4 -# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 -# tab). -indent-string=' ' +[CLASSES] -# Maximum number of characters on a single line. -max-line-length=120 +# Warn about protected attribute access inside special methods +check-protected-access-in-special-methods=no -# Maximum number of lines in a module. -max-module-lines=1000 +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__, + __new__, + setUp, + asyncSetUp, + __post_init__ -# Allow the body of a class to be on the same line as the declaration if body -# contains single statement. -single-line-class-stmt=no +# List of member names, which should be excluded from the protected access +# warning. +exclude-protected=_asdict,_fields,_replace,_source,_make,os._exit -# Allow the body of an if to be on the same line as the test if there is no -# else. -single-line-if-stmt=no +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls +# List of valid names for the first argument in a metaclass class method. +valid-metaclass-classmethod-first-arg=mcs -[EXCEPTIONS] -# Exceptions that will emit a warning when caught. -overgeneral-exceptions=builtins.BaseException, - builtins.Exception +[DESIGN] +# List of regular expressions of class ancestor names to ignore when counting +# public methods (see R0903) +exclude-too-few-public-methods= -[VARIABLES] +# List of qualified class names to ignore when counting class parents (see +# R0901) +ignored-parents= -# List of additional names supposed to be defined in builtins. Remember that -# you should avoid defining new builtins when possible. -additional-builtins= +# Maximum number of arguments for function / method. +max-args=5 -# Tells whether unused global variables should be treated as a violation. -allow-global-unused-variables=yes +# Maximum number of attributes for a class (see R0902). +max-attributes=7 -# List of names allowed to shadow builtins -allowed-redefined-builtins= +# Maximum number of boolean expressions in an if statement (see R0916). +max-bool-expr=5 -# List of strings which can identify a callback function by name. A callback -# name must start or end with one of those strings. -callbacks=cb_, - _cb +# Maximum number of branch for function / method body. +max-branches=12 -# A regular expression matching the name of dummy variables (i.e. expected to -# not be used). -dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ - -# Argument names that match this expression will be ignored. -ignored-argument-names=_.*|^ignored_|^unused_ - -# Tells whether we should check for unused import in __init__ files. -init-import=no - -# List of qualified module names which can have objects that can redefine -# builtins. -redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io - - -[SPELLING] - -# Limits count of emitted suggestions for spelling mistakes. -max-spelling-suggestions=4 - -# Spelling dictionary name. Available dictionaries: none. To make it work, -# install the 'python-enchant' package. -spelling-dict= +# Maximum number of locals for function / method body. +max-locals=15 -# List of comma separated words that should be considered directives if they -# appear at the beginning of a comment and should not be checked. -spelling-ignore-comment-directives=fmt: on,fmt: off,noqa:,noqa,nosec,isort:skip,mypy: +# Maximum number of parents for a class (see R0901). +max-parents=7 -# List of comma separated words that should not be checked. -spelling-ignore-words= +# Maximum number of public methods for a class (see R0904). +max-public-methods=20 -# A path to a file that contains the private dictionary; one word per line. -spelling-private-dict-file= +# Maximum number of return / yield for function / method body. +max-returns=6 -# Tells whether to store unknown words to the private dictionary (see the -# --spelling-private-dict-file option) instead of raising a message. -spelling-store-unknown-words=no +# Maximum number of statements in function / method body. +max-statements=50 +# Minimum number of public methods for a class (see R0903). +min-public-methods=2 -[DESIGN] -# List of regular expressions of class ancestor names to ignore when counting -# public methods (see R0903) -exclude-too-few-public-methods= +[EXCEPTIONS] -# List of qualified class names to ignore when counting class parents (see -# R0901) -ignored-parents= +# Exceptions that will emit a warning when caught. +overgeneral-exceptions=builtins.BaseException,builtins.Exception -# Maximum number of arguments for function / method. -max-args=5 -# Maximum number of attributes for a class (see R0902). -max-attributes=7 +[FORMAT] -# Maximum number of boolean expressions in an if statement (see R0916). -max-bool-expr=5 +# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. +expected-line-ending-format= -# Maximum number of branch for function / method body. -max-branches=12 +# Regexp for a line that is allowed to be longer than the limit. +ignore-long-lines=^\s*(# )??$ -# Maximum number of locals for function / method body. -max-locals=15 +# Number of spaces of indent required inside a hanging or continued line. +indent-after-paren=4 -# Maximum number of parents for a class (see R0901). -max-parents=7 +# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 +# tab). +indent-string=' ' -# Maximum number of public methods for a class (see R0904). -max-public-methods=20 +# Maximum number of characters on a single line. +max-line-length=120 -# Maximum number of return / yield for function / method body. -max-returns=6 +# Maximum number of lines in a module. +max-module-lines=1000 -# Maximum number of statements in function / method body. -max-statements=50 +# Allow the body of a class to be on the same line as the declaration if body +# contains single statement. +single-line-class-stmt=no -# Minimum number of public methods for a class (see R0903). -min-public-methods=2 +# Allow the body of an if to be on the same line as the test if there is no +# else. +single-line-if-stmt=no [IMPORTS] @@ -372,6 +357,9 @@ min-public-methods=2 # one. allow-any-import-level= +# Allow explicit reexports by alias from a package __init__. +allow-reexport-from-package=no + # Allow wildcard imports from modules that define __all__. allow-wildcard-with-all=no @@ -402,140 +390,55 @@ known-third-party=enchant preferred-modules= -[BASIC] - -# Naming style matching correct argument names. -argument-naming-style=snake_case - -# Regular expression matching correct argument names. Overrides argument- -# naming-style. If left empty, argument names will be checked with the set -# naming style. -#argument-rgx= - -# Naming style matching correct attribute names. -attr-naming-style=snake_case - -# Regular expression matching correct attribute names. Overrides attr-naming- -# style. If left empty, attribute names will be checked with the set naming -# style. -attr-rgx=[a-z_][a-z0-9_]{1,40}$ - -# Bad variable names which should always be refused, separated by a comma. -bad-names=foo, - bar, - baz, - toto, - tutu, - tata - -# Bad variable names regexes, separated by a comma. If names match any regex, -# they will always be refused -bad-names-rgxs= - -# Naming style matching correct class attribute names. -class-attribute-naming-style=any - -# Regular expression matching correct class attribute names. Overrides class- -# attribute-naming-style. If left empty, class attribute names will be checked -# with the set naming style. -#class-attribute-rgx= - -# Naming style matching correct class constant names. -class-const-naming-style=UPPER_CASE - -# Regular expression matching correct class constant names. Overrides class- -# const-naming-style. If left empty, class constant names will be checked with -# the set naming style. -#class-const-rgx= - -# Naming style matching correct class names. -class-naming-style=PascalCase - -# Regular expression matching correct class names. Overrides class-naming- -# style. If left empty, class names will be checked with the set naming style. -#class-rgx= - -# Naming style matching correct constant names. -const-naming-style=UPPER_CASE - -# Regular expression matching correct constant names. Overrides const-naming- -# style. If left empty, constant names will be checked with the set naming -# style. -#const-rgx= - -# Minimum line length for functions/classes that require docstrings, shorter -# ones are exempt. -docstring-min-length=-2 - -# Naming style matching correct function names. -function-naming-style=snake_case - -# Regular expression matching correct function names. Overrides function- -# naming-style. If left empty, function names will be checked with the set -# naming style. -#function-rgx= - -# Good variable names which should always be accepted, separated by a comma. -good-names=i, - j, - k, - ex, - Run, - _ - -# Good variable names regexes, separated by a comma. If names match any regex, -# they will always be accepted -good-names-rgxs= - -# Include a hint for the correct naming format with invalid-name. -include-naming-hint=yes - -# Naming style matching correct inline iteration names. -inlinevar-naming-style=any - -# Regular expression matching correct inline iteration names. Overrides -# inlinevar-naming-style. If left empty, inline iteration names will be checked -# with the set naming style. -#inlinevar-rgx= +[LOGGING] -# Naming style matching correct method names. -method-naming-style=snake_case +# The type of string formatting that logging methods do. `old` means using % +# formatting, `new` is for `{}` formatting. +logging-format-style=old -# Regular expression matching correct method names. Overrides method-naming- -# style. If left empty, method names will be checked with the set naming style. -#method-rgx= +# Logging modules to check that the string format arguments are in logging +# function parameter format. +logging-modules=logging -# Naming style matching correct module names. -module-naming-style=snake_case -# Regular expression matching correct module names. Overrides module-naming- -# style. If left empty, module names will be checked with the set naming style. -#module-rgx= +[MESSAGES CONTROL] -# Colon-delimited sets of names that determine each other's naming style when -# the name regexes allow several styles. -name-group= +# Only show warnings with the listed confidence levels. Leave empty to show +# all. Valid levels: HIGH, CONTROL_FLOW, INFERENCE, INFERENCE_FAILURE, +# UNDEFINED. +confidence=HIGH, + CONTROL_FLOW, + INFERENCE, + INFERENCE_FAILURE, + UNDEFINED -# Regular expression which should only match function or class names that do -# not require a docstring. -no-docstring-rgx=^_ +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once). You can also use "--disable=all" to +# disable everything first and then re-enable specific checks. For example, if +# you want to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use "--disable=all --enable=classes +# --disable=W". +disable=duplicate-code, + too-few-public-methods, + missing-module-docstring, + too-many-instance-attributes, + too-many-arguments, -# List of decorators that produce properties, such as abc.abstractproperty. Add -# to this list to register other decorators that produce valid properties. -# These decorators are taken in consideration only for invalid-name. -property-classes=abc.abstractproperty +# Enable the message, report, category or checker with the given id(s). You can +# either give multiple identifier separated by comma (,) or put this option +# multiple time (only on the command line, not in the configuration file where +# it should appear only once). See also the "--disable" option for examples. +enable=c-extension-no-member, -# Regular expression matching correct type variable names. If left empty, type -# variable names will be checked with the set naming style. -typevar-rgx=^Type[a-zA-Z0-9_]+$ -# Naming style matching correct variable names. -variable-naming-style=snake_case +[METHOD_ARGS] -# Regular expression matching correct variable names. Overrides variable- -# naming-style. If left empty, variable names will be checked with the set -# naming style. -#variable-rgx= +# List of qualified names (i.e., library.method) which require a timeout +# parameter e.g. 'requests.api.get,requests.api.post' +timeout-methods=requests.api.delete,requests.api.get,requests.api.head,requests.api.options,requests.api.patch,requests.api.post,requests.api.put,requests.api.request [MISCELLANEOUS] @@ -561,22 +464,71 @@ max-nested-blocks=5 never-returning-functions=sys.exit,argparse.parse_error -[METHOD_ARGS] +[REPORTS] -# List of qualified names (i.e., library.method) which require a timeout -# parameter e.g. 'requests.api.get,requests.api.post' -timeout-methods=requests.api.delete,requests.api.get,requests.api.head,requests.api.options,requests.api.patch,requests.api.post,requests.api.put,requests.api.request +# Python expression which should return a score less than or equal to 10. You +# have access to the variables 'fatal', 'error', 'warning', 'refactor', +# 'convention', and 'info' which contain the number of messages in each +# category, as well as 'statement' which is the total number of statements +# analyzed. This score is used by the global evaluation report (RP0004). +evaluation=max(0, 0 if fatal else 10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)) +# Template used to display messages. This is a python new-style format string +# used to format the message information. See doc for all details. +msg-template= -[LOGGING] +# Set the output format. Available formats are text, parseable, colorized, json +# and msvs (visual studio). You can also give a reporter class, e.g. +# mypackage.mymodule.MyReporterClass. +#output-format= -# The type of string formatting that logging methods do. `old` means using % -# formatting, `new` is for `{}` formatting. -logging-format-style=old +# Tells whether to display a full report or only the messages. +reports=no -# Logging modules to check that the string format arguments are in logging -# function parameter format. -logging-modules=logging +# Activate the evaluation score. +score=yes + + +[SIMILARITIES] + +# Comments are removed from the similarity computation +ignore-comments=yes + +# Docstrings are removed from the similarity computation +ignore-docstrings=yes + +# Imports are removed from the similarity computation +ignore-imports=yes + +# Signatures are removed from the similarity computation +ignore-signatures=yes + +# Minimum lines number of a similarity. +min-similarity-lines=4 + + +[SPELLING] + +# Limits count of emitted suggestions for spelling mistakes. +max-spelling-suggestions=4 + +# Spelling dictionary name. No available dictionaries : You need to install +# both the python package and the system dependency for enchant to work.. +spelling-dict= + +# List of comma separated words that should be considered directives if they +# appear at the beginning of a comment and should not be checked. +spelling-ignore-comment-directives=fmt: on,fmt: off,noqa:,noqa,nosec,isort:skip,mypy: + +# List of comma separated words that should not be checked. +spelling-ignore-words= + +# A path to a file that contains the private dictionary; one word per line. +spelling-private-dict-file= + +# Tells whether to store unknown words to the private dictionary (see the +# --spelling-private-dict-file option) instead of raising a message. +spelling-store-unknown-words=no [STRING] @@ -590,27 +542,87 @@ check-quote-consistency=no check-str-concat-over-line-jumps=no -[CLASSES] +[TYPECHECK] -# Warn about protected attribute access inside special methods -check-protected-access-in-special-methods=no +# List of decorators that produce context managers, such as +# contextlib.contextmanager. Add to this list to register other decorators that +# produce valid context managers. +contextmanager-decorators=contextlib.contextmanager -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__, - __new__, - setUp, - __post_init__ +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E1101 when accessed. Python regular +# expressions are accepted. +generated-members= -# List of member names, which should be excluded from the protected access -# warning. -exclude-protected=_asdict, - _fields, - _replace, - _source, - _make +# Tells whether to warn about missing members when the owner of the attribute +# is inferred to be None. +ignore-none=yes -# List of valid names for the first argument in a class method. -valid-classmethod-first-arg=cls +# This flag controls whether pylint should warn about no-member and similar +# checks whenever an opaque object is returned when inferring. The inference +# can return multiple potential results while evaluating a Python object, but +# some branches might not be evaluated, which results in partial inference. In +# that case, it might be useful to still emit no-member and other checks for +# the rest of the inferred objects. +ignore-on-opaque-inference=yes -# List of valid names for the first argument in a metaclass class method. -valid-metaclass-classmethod-first-arg=cls +# List of symbolic message names to ignore for Mixin members. +ignored-checks-for-mixins=no-member, + not-async-context-manager, + not-context-manager, + attribute-defined-outside-init + +# List of class names for which member attributes should not be checked (useful +# for classes with dynamically set attributes). This supports the use of +# qualified names. +ignored-classes=optparse.Values,thread._local,_thread._local,argparse.Namespace + +# Show a hint with possible names when a member name was not found. The aspect +# of finding the hint is based on edit distance. +missing-member-hint=yes + +# The minimum edit distance a name should have in order to be considered a +# similar match for a missing member name. +missing-member-hint-distance=1 + +# The total number of similar names that should be taken in consideration when +# showing a hint for a missing member. +missing-member-max-choices=1 + +# Regex pattern to define which classes are considered mixins. +mixin-class-rgx=.*[Mm]ixin + +# List of decorators that change the signature of a decorated function. +signature-mutators= + + +[VARIABLES] + +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid defining new builtins when possible. +additional-builtins= + +# Tells whether unused global variables should be treated as a violation. +allow-global-unused-variables=yes + +# List of names allowed to shadow builtins +allowed-redefined-builtins= + +# List of strings which can identify a callback function by name. A callback +# name must start or end with one of those strings. +callbacks=cb_, + _cb + +# A regular expression matching the name of dummy variables (i.e. expected to +# not be used). +dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ + +# Argument names that match this expression will be ignored. +ignored-argument-names=_.*|^ignored_|^unused_ + +# Tells whether we should check for unused import in __init__ files. +init-import=no + +# List of qualified module names which can have objects that can redefine +# builtins. +redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io diff --git a/mindee/client.py b/mindee/client.py index 27b45184..d0a4229d 100644 --- a/mindee/client.py +++ b/mindee/client.py @@ -89,7 +89,8 @@ def parse( Set to ``False`` if you need to access the file after this operation. :param page_options: If set, remove pages from the document as specified. - This is done before sending the file to the server and is useful to avoid page limitations. + This is done before sending the file to the server. + It is useful to avoid page limitations. :param cropper: Whether to include cropper results for each page. This performs a cropping operation on the server and will increase response time. @@ -141,7 +142,8 @@ def enqueue( Set to ``False`` if you need to access the file after this operation. :param page_options: If set, remove pages from the document as specified. - This is done before sending the file to the server and is useful to avoid page limitations. + This is done before sending the file to the server. + It is useful to avoid page limitations. :param cropper: Whether to include cropper results for each page. This performs a cropping operation on the server and will increase response time. @@ -229,7 +231,8 @@ def enqueue_and_parse( Set to ``False`` if you need to access the file after this operation. :param page_options: If set, remove pages from the document as specified. - This is done before sending the file to the server and is useful to avoid page limitations. + This is done before sending the file to the server. + It is useful to avoid page limitations. :param cropper: Whether to include cropper results for each page. This performs a cropping operation on the server and will increase response time. diff --git a/mindee/input/sources.py b/mindee/input/sources.py index a67b5369..57877d09 100644 --- a/mindee/input/sources.py +++ b/mindee/input/sources.py @@ -70,10 +70,12 @@ def fix_pdf(self, maximum_offset: int = 500) -> None: WARNING: this feature alters the data of the enqueued file by removing unnecessary headers. - Reads the bytes of a PDF file until a proper pdf tag is encountered, or until the maximum offset has been - reached. If a tag denoting a PDF file is found, deletes all bytes before it. + Reads the bytes of a PDF file until a proper pdf tag is encountered, + or until the maximum offset has been reached. + If a tag denoting a PDF file is found, deletes all bytes before it. - :param maximum_offset: maximum byte offset where superfluous headers will be removed. Cannot be less than 0. + :param maximum_offset: maximum byte offset where superfluous headers will be removed. + Cannot be less than 0. """ if maximum_offset < 0: raise MindeeError("Can't set maximum offset for pdf-fixing to less than 0.") diff --git a/mindee/parsing/common/inference.py b/mindee/parsing/common/inference.py index c254ceb1..f4c91b6f 100644 --- a/mindee/parsing/common/inference.py +++ b/mindee/parsing/common/inference.py @@ -2,7 +2,7 @@ from mindee.error.mindee_error import MindeeError from mindee.parsing.common.page import TypePage -from mindee.parsing.common.prediction import Prediction, TypePrediction +from mindee.parsing.common.prediction import TypePrediction from mindee.parsing.common.product import Product from mindee.parsing.common.string_dict import StringDict @@ -16,7 +16,7 @@ class Inference(Generic[TypePrediction, TypePage]): """Name of the endpoint for OTS APIs""" endpoint_version: Optional[str] """Version of the endpoint for OTS APIs""" - prediction: Prediction + prediction: TypePrediction """A document's top-level Prediction.""" pages: List[TypePage] """A document's pages.""" @@ -40,7 +40,7 @@ def __str__(self) -> str: if self.prediction and len(str(self.prediction)) > 0: prediction_str = f"{str(self.prediction)}\n" if len(self.pages) > 0: - pages_str = ("\nPage Predictions\n================\n\n") + "\n".join( + pages_str = "\nPage Predictions\n================\n\n" + "\n".join( [str(page) for page in self.pages] ) return ( diff --git a/mindee/parsing/custom/line_items.py b/mindee/parsing/custom/line_items.py index 5cdb8e59..29c56e3f 100644 --- a/mindee/parsing/custom/line_items.py +++ b/mindee/parsing/custom/line_items.py @@ -72,10 +72,10 @@ def update_field(self, field_name: str, field_value: ListFieldValue) -> None: def is_box_in_line(line: CustomLine, bbox: BBox, height_line_tolerance: float) -> bool: """ - Checks if the bbox fits inside the line. + Checks if the bbox fits inside the given line. - :param anchor_name: name of the anchor. - :param fields: fields to build lines from. + :param line: Line to check. + :param bbox: Bbox to check. :param height_line_tolerance: line height tolerance for custom line reconstruction. """ if abs(bbox.y_min - line.bbox.y_min) <= height_line_tolerance: diff --git a/mindee/product/barcode_reader/barcode_reader_v1_document.py b/mindee/product/barcode_reader/barcode_reader_v1_document.py index a5c2c893..8171011e 100644 --- a/mindee/product/barcode_reader/barcode_reader_v1_document.py +++ b/mindee/product/barcode_reader/barcode_reader_v1_document.py @@ -23,6 +23,7 @@ def __init__( :param raw_prediction: Raw prediction from HTTP response :param page_id: Page number for multi pages pdf input """ + super().__init__(raw_prediction, page_id) self.codes_1d = [ StringField(prediction, page_id=page_id) for prediction in raw_prediction["codes_1d"] diff --git a/mindee/product/custom/custom_v1_document.py b/mindee/product/custom/custom_v1_document.py index 4aa2bb2c..07e19a86 100644 --- a/mindee/product/custom/custom_v1_document.py +++ b/mindee/product/custom/custom_v1_document.py @@ -19,6 +19,7 @@ def __init__(self, raw_prediction: StringDict) -> None: :param raw_prediction: Dictionary containing the JSON document response """ + super().__init__(raw_prediction) self.fields = {} self.classifications = {} for field_name, field_contents in raw_prediction.items(): diff --git a/mindee/product/custom/custom_v1_page.py b/mindee/product/custom/custom_v1_page.py index 31e3170a..ae3a9a89 100644 --- a/mindee/product/custom/custom_v1_page.py +++ b/mindee/product/custom/custom_v1_page.py @@ -17,6 +17,7 @@ def __init__(self, raw_prediction: StringDict, page_id: Optional[int]) -> None: :param raw_prediction: Dictionary containing the JSON document response """ + super().__init__(raw_prediction, page_id) self.fields = {} for field_name, field_contents in raw_prediction.items(): self.fields[field_name] = ListField(field_contents, page_id=page_id) diff --git a/mindee/product/eu/license_plate/license_plate_v1_document.py b/mindee/product/eu/license_plate/license_plate_v1_document.py index 08e9f985..8678500f 100644 --- a/mindee/product/eu/license_plate/license_plate_v1_document.py +++ b/mindee/product/eu/license_plate/license_plate_v1_document.py @@ -21,6 +21,7 @@ def __init__( :param raw_prediction: Raw prediction from HTTP response :param page_id: Page number for multi pages pdf input """ + super().__init__(raw_prediction, page_id) self.license_plates = [ StringField(prediction, page_id=page_id) for prediction in raw_prediction["license_plates"] diff --git a/mindee/product/financial_document/financial_document_v1_document.py b/mindee/product/financial_document/financial_document_v1_document.py index 3f1eacb2..1f2bdf9c 100644 --- a/mindee/product/financial_document/financial_document_v1_document.py +++ b/mindee/product/financial_document/financial_document_v1_document.py @@ -77,6 +77,7 @@ def __init__( :param raw_prediction: Raw prediction from HTTP response :param page_id: Page number for multi pages pdf input """ + super().__init__(raw_prediction, page_id) self.category = ClassificationField( raw_prediction["category"], page_id=page_id, diff --git a/mindee/product/fr/bank_account_details/bank_account_details_v1_document.py b/mindee/product/fr/bank_account_details/bank_account_details_v1_document.py index 91f424bc..629e040e 100644 --- a/mindee/product/fr/bank_account_details/bank_account_details_v1_document.py +++ b/mindee/product/fr/bank_account_details/bank_account_details_v1_document.py @@ -25,6 +25,7 @@ def __init__( :param raw_prediction: Raw prediction from HTTP response :param page_id: Page number for multi pages pdf input """ + super().__init__(raw_prediction, page_id) self.account_holder_name = StringField( raw_prediction["account_holder_name"], page_id=page_id, diff --git a/mindee/product/fr/bank_account_details/bank_account_details_v2_document.py b/mindee/product/fr/bank_account_details/bank_account_details_v2_document.py index 9ebd26b0..134901e5 100644 --- a/mindee/product/fr/bank_account_details/bank_account_details_v2_document.py +++ b/mindee/product/fr/bank_account_details/bank_account_details_v2_document.py @@ -30,6 +30,7 @@ def __init__( :param raw_prediction: Raw prediction from HTTP response :param page_id: Page number for multi pages pdf input """ + super().__init__(raw_prediction, page_id) self.account_holders_names = StringField( raw_prediction["account_holders_names"], page_id=page_id, diff --git a/mindee/product/fr/carte_grise/carte_grise_v1_document.py b/mindee/product/fr/carte_grise/carte_grise_v1_document.py index 9ec39355..9009e939 100644 --- a/mindee/product/fr/carte_grise/carte_grise_v1_document.py +++ b/mindee/product/fr/carte_grise/carte_grise_v1_document.py @@ -101,6 +101,7 @@ def __init__( :param raw_prediction: Raw prediction from HTTP response :param page_id: Page number for multi pages pdf input """ + super().__init__(raw_prediction, page_id) self.a = StringField( raw_prediction["a"], page_id=page_id, diff --git a/mindee/product/fr/carte_vitale/carte_vitale_v1_document.py b/mindee/product/fr/carte_vitale/carte_vitale_v1_document.py index d65ded13..777ea596 100644 --- a/mindee/product/fr/carte_vitale/carte_vitale_v1_document.py +++ b/mindee/product/fr/carte_vitale/carte_vitale_v1_document.py @@ -27,6 +27,7 @@ def __init__( :param raw_prediction: Raw prediction from HTTP response :param page_id: Page number for multi pages pdf input """ + super().__init__(raw_prediction, page_id) self.given_names = [ StringField(prediction, page_id=page_id) for prediction in raw_prediction["given_names"] diff --git a/mindee/product/fr/id_card/id_card_v1_document.py b/mindee/product/fr/id_card/id_card_v1_document.py index 1547f139..07b178d0 100644 --- a/mindee/product/fr/id_card/id_card_v1_document.py +++ b/mindee/product/fr/id_card/id_card_v1_document.py @@ -39,6 +39,7 @@ def __init__( :param raw_prediction: Raw prediction from HTTP response :param page_id: Page number for multi pages pdf input """ + super().__init__(raw_prediction, page_id) self.authority = StringField( raw_prediction["authority"], page_id=page_id, diff --git a/mindee/product/fr/id_card/id_card_v2_document.py b/mindee/product/fr/id_card/id_card_v2_document.py index c19924fc..19b83955 100644 --- a/mindee/product/fr/id_card/id_card_v2_document.py +++ b/mindee/product/fr/id_card/id_card_v2_document.py @@ -49,6 +49,7 @@ def __init__( :param raw_prediction: Raw prediction from HTTP response :param page_id: Page number for multi pages pdf input """ + super().__init__(raw_prediction, page_id) self.alternate_name = StringField( raw_prediction["alternate_name"], page_id=page_id, diff --git a/mindee/product/invoice/invoice_v4_document.py b/mindee/product/invoice/invoice_v4_document.py index 9795e280..f9975366 100644 --- a/mindee/product/invoice/invoice_v4_document.py +++ b/mindee/product/invoice/invoice_v4_document.py @@ -63,6 +63,7 @@ def __init__( :param raw_prediction: Raw prediction from HTTP response :param page_id: Page number for multi pages pdf input """ + super().__init__(raw_prediction, page_id) self.customer_address = StringField( raw_prediction["customer_address"], page_id=page_id, diff --git a/mindee/product/invoice_splitter/invoice_splitter_v1_document.py b/mindee/product/invoice_splitter/invoice_splitter_v1_document.py index 26e44449..6fee18f9 100644 --- a/mindee/product/invoice_splitter/invoice_splitter_v1_document.py +++ b/mindee/product/invoice_splitter/invoice_splitter_v1_document.py @@ -18,6 +18,8 @@ def __init__(self, raw_prediction: StringDict) -> None: :param raw_prediction: Raw prediction from HTTP response """ + super().__init__(raw_prediction) + invoice_page_groups = [] if ( "invoice_page_groups" in raw_prediction diff --git a/mindee/product/material_certificate/material_certificate_v1_document.py b/mindee/product/material_certificate/material_certificate_v1_document.py index 66c8987f..7ef792e0 100644 --- a/mindee/product/material_certificate/material_certificate_v1_document.py +++ b/mindee/product/material_certificate/material_certificate_v1_document.py @@ -25,6 +25,7 @@ def __init__( :param raw_prediction: Raw prediction from HTTP response :param page_id: Page number for multi pages pdf input """ + super().__init__(raw_prediction, page_id) self.certificate_type = StringField( raw_prediction["certificate_type"], page_id=page_id, diff --git a/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_document.py b/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_document.py index 42eb2e45..b25e62d2 100644 --- a/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_document.py +++ b/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_document.py @@ -21,6 +21,7 @@ def __init__( :param raw_prediction: Raw prediction from HTTP response :param page_id: Page number for multi pages pdf input """ + super().__init__(raw_prediction, page_id) self.receipts = [ PositionField(prediction, page_id=page_id) for prediction in raw_prediction["receipts"] diff --git a/mindee/product/passport/passport_v1_document.py b/mindee/product/passport/passport_v1_document.py index ed6f1918..ae364a55 100644 --- a/mindee/product/passport/passport_v1_document.py +++ b/mindee/product/passport/passport_v1_document.py @@ -41,6 +41,7 @@ def __init__( :param raw_prediction: Raw prediction from HTTP response :param page_id: Page number for multi pages pdf input """ + super().__init__(raw_prediction, page_id) self.birth_date = DateField( raw_prediction["birth_date"], page_id=page_id, diff --git a/mindee/product/proof_of_address/proof_of_address_v1_document.py b/mindee/product/proof_of_address/proof_of_address_v1_document.py index c630046c..50e5080e 100644 --- a/mindee/product/proof_of_address/proof_of_address_v1_document.py +++ b/mindee/product/proof_of_address/proof_of_address_v1_document.py @@ -42,6 +42,7 @@ def __init__( :param raw_prediction: Raw prediction from HTTP response :param page_id: Page number for multi pages pdf input """ + super().__init__(raw_prediction, page_id) self.date = DateField( raw_prediction["date"], page_id=page_id, diff --git a/mindee/product/receipt/receipt_v5_document.py b/mindee/product/receipt/receipt_v5_document.py index 17ae9a27..9d746dd1 100644 --- a/mindee/product/receipt/receipt_v5_document.py +++ b/mindee/product/receipt/receipt_v5_document.py @@ -60,6 +60,7 @@ def __init__( :param raw_prediction: Raw prediction from HTTP response :param page_id: Page number for multi pages pdf input """ + super().__init__(raw_prediction, page_id) self.category = ClassificationField( raw_prediction["category"], page_id=page_id, diff --git a/mindee/product/us/bank_check/bank_check_v1_document.py b/mindee/product/us/bank_check/bank_check_v1_document.py index 6cf6b959..21202a0d 100644 --- a/mindee/product/us/bank_check/bank_check_v1_document.py +++ b/mindee/product/us/bank_check/bank_check_v1_document.py @@ -31,6 +31,7 @@ def __init__( :param raw_prediction: Raw prediction from HTTP response :param page_id: Page number for multi pages pdf input """ + super().__init__(raw_prediction, page_id) self.account_number = StringField( raw_prediction["account_number"], page_id=page_id, diff --git a/mindee/product/us/driver_license/driver_license_v1_document.py b/mindee/product/us/driver_license/driver_license_v1_document.py index 163fd6e6..cfae6109 100644 --- a/mindee/product/us/driver_license/driver_license_v1_document.py +++ b/mindee/product/us/driver_license/driver_license_v1_document.py @@ -53,6 +53,7 @@ def __init__( :param raw_prediction: Raw prediction from HTTP response :param page_id: Page number for multi pages pdf input """ + super().__init__(raw_prediction, page_id) self.address = StringField( raw_prediction["address"], page_id=page_id, diff --git a/setup.cfg b/setup.cfg index fd109376..ac8a0e45 100644 --- a/setup.cfg +++ b/setup.cfg @@ -49,8 +49,8 @@ mindee = [options.extras_require] dev = black==23.10.0 - mypy==1.4.1 - pylint==2.17.1 + mypy==1.6.1 + pylint==2.17.7 setuptools==51.3.3 isort==5.11.5 pre-commit~=2.21.0