From c715646219361dd3f4e9e70e53833e9e0d568355 Mon Sep 17 00:00:00 2001 From: actionless Date: Tue, 16 Jul 2024 09:33:36 +0200 Subject: [PATCH] chore: move the contents of mypy.ini and .pylintrc into pyproject.toml --- .pylintrc | 374 --------------------------------------------- mypy.ini | 20 --- oomox_gui/color.py | 6 +- oomox_gui/main.py | 2 +- pyproject.toml | 135 +++++++++++++++- 5 files changed, 137 insertions(+), 400 deletions(-) delete mode 100644 .pylintrc delete mode 100644 mypy.ini diff --git a/.pylintrc b/.pylintrc deleted file mode 100644 index 38e9f805..00000000 --- a/.pylintrc +++ /dev/null @@ -1,374 +0,0 @@ -[GENERAL] - -# A comma-separated list of package or module names from where C extensions may -# be loaded. Extensions are loading into the active Python interpreter and may -# run arbitrary code -#extension-pkg-whitelist=gi -extension-pkg-allow-list=gi - -# Add files or directories to the blacklist. They should be base names, not -# paths. -ignore=CVS - -# Add files or directories matching the regex patterns to the blacklist. The -# regex matches against base names, not paths. -ignore-patterns= - -# Python code to execute, usually for sys.path manipulation such as -# pygtk.require(). -#init-hook= - -# Use multiple processes to speed up Pylint. -#jobs=4 - -# List of plugins (as comma separated values of python modules names) to load, -# usually to register additional checkers. -load-plugins= - -# Pickle collected data for later comparisons. -persistent=yes - -# Specify a configuration file. -#rcfile= - -# Allow loading of arbitrary C extensions. Extensions are imported into the -# active Python interpreter and may run arbitrary code. -unsafe-load-any-extension=no - - -[MESSAGES CONTROL] - -# Only show warnings with the listed confidence levels. Leave empty to show -# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED -confidence= - -# 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 reenable 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-docstring,cyclic-import #,similarities -disable=too-few-public-methods,missing-docstring,cyclic-import,similarities -#print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call - -# 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=useless-suppression - - -[REPORTS] - -# Python expression which should return a note less than 10 (10 is the highest -# note). You have access to the variables errors warning, statement which -# respectively contain the number of errors / warnings messages and the total -# number of statements analyzed. This is used by the global evaluation report -# (RP0004). -evaluation=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= - -# Set the output format. Available formats are text, parseable, colorized, json -# and msvs (visual studio).You can also give a reporter class, eg -# mypackage.mymodule.MyReporterClass. -output-format=text - -# Tells whether to display a full report or only the messages -reports=no - -# Activate the evaluation score. -score=yes - - -[REFACTORING] - -# Maximum number of nested blocks for function / method body -max-nested-blocks=5 - - -[FORMAT] - -# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. -expected-line-ending-format= - -# Regexp for a line that is allowed to be longer than the limit. -ignore-long-lines=^\s*(# )??$ - -# 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=' ' - -# Maximum number of characters on a single line. -max-line-length=120 - -# Maximum number of lines in a module -max-module-lines=1000 - -# 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 - - -[TYPECHECK] - -# 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 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=self.props - -# 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 - -# List of module names for which member attributes should not be checked -# (useful for modules/projects where namespaces are manipulated during runtime -# and thus existing member attributes cannot be deduced by static analysis. It -# supports qualified module names, as well as Unix pattern matching. -ignored-modules= - -# 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 - - -[SIMILARITIES] - -# Ignore comments when computing similarities. -ignore-comments=yes - -# Ignore docstrings when computing similarities. -ignore-docstrings=yes - -# Ignore imports when computing similarities. -ignore-imports=no - -# Minimum lines number of a similarity. -min-similarity-lines=8 - - -[LOGGING] - -# Logging modules to check that the string format arguments are in logging -# function parameter format -logging-modules=logging - - -[SPELLING] - -# Spelling dictionary name. Available dictionaries: none. To make it working -# install python-enchant package. -spelling-dict= - -# List of comma separated words that should not be checked. -spelling-ignore-words= - -# A path to a file that contains private dictionary; one word per line. -spelling-private-dict-file= - -# Tells whether to store unknown words to indicated private dictionary in -# --spelling-private-dict-file option instead of raising a message. -spelling-store-unknown-words=no - - -[VARIABLES] - -# List of additional names supposed to be defined in builtins. Remember that -# you should avoid to define new builtins when possible. -additional-builtins= - -# Tells whether unused global variables should be treated as a violation. -allow-global-unused-variables=yes - -# 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. expectedly -# not used). -dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy - -# Argument names that match this expression will be ignored. Default to name -# with leading underscore -ignored-argument-names=_.* - -# 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,future.builtins - - -[MISCELLANEOUS] - -# List of note tags to take in consideration, separated by a comma. -notes=FIXME,XXX -#notes=FIXME,XXX,TODO,@TODO - - -[BASIC] - -# Regular expression matching correct argument names -argument-rgx=(([a-z][a-z0-9_]{2,36})|(_[a-z0-9_]*))$ - -# Regular expression matching correct attribute names -attr-rgx=(([a-z][a-z0-9_]{2,36})|(_[a-z0-9_]*))$ - -# Bad variable names which should always be refused, separated by a comma -bad-names=foo,bar,baz,toto,tutu,tata - -# Regular expression matching correct class attribute names -class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,36}|(__.*__))$ - -# Regular expression matching correct class names -class-rgx=[A-Z_][a-zA-Z0-9]+$ - -# Regular expression matching correct constant names -const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - -# Minimum line length for functions/classes that require docstrings, shorter -# ones are exempt. -docstring-min-length=-1 - -# Regular expression matching correct function names -function-rgx=(([a-z][a-z0-9_]{2,40})|(_[a-z0-9_]*))$ - -# Good variable names which should always be accepted, separated by a comma -good-names=i,j,k,ex,Run,_ - -# Include a hint for the correct naming format with invalid-name -include-naming-hint=no - -# Regular expression matching correct inline iteration names -inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ - -# Regular expression matching correct method names -method-rgx=(([a-z][a-z0-9_]{2,36})|(_[a-z0-9_]*))$ - -# Regular expression matching correct module names -module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - -# Colon-delimited sets of names that determine each other's naming style when -# the name regexes allow several styles. -name-group= - -# Regular expression which should only match function or class names that do -# not require a docstring. -no-docstring-rgx=^_ - -# List of decorators that produce properties, such as abc.abstractproperty. Add -# to this list to register other decorators that produce valid properties. -property-classes=abc.abstractproperty - -# Regular expression matching correct variable names -variable-rgx=(([a-z][a-z0-9_]{2,36})|(_[a-z0-9_]*)|r|g|b)$ - - -[CLASSES] - -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__,__new__,setUp - -# List of member names, which should be excluded from the protected access -# warning. -exclude-protected=_asdict,_fields,_replace,_source,_make - -# 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 - - -[DESIGN] - -# Maximum number of arguments for function / method -max-args=8 - -# Maximum number of attributes for a class (see R0902). -max-attributes=16 - -# Maximum number of boolean expressions in a if statement -max-bool-expr=5 - -# Maximum number of branch for function / method body -max-branches=12 - -# Maximum number of locals for function / method body -max-locals=15 - -# Maximum number of parents for a class (see R0901). -max-parents=7 - -# Maximum number of public methods for a class (see R0904). -max-public-methods=20 - -# Maximum number of return / yield for function / method body -max-returns=6 - -# 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 - - -[IMPORTS] - -# Analyse import fallback blocks. This can be used to support both Python 2 and -# 3 compatible code, which means that the block might have code that exists -# only in one or another interpreter, leading to false positives when analysed. -analyse-fallback-blocks=no - -# Deprecated modules which should not be used, separated by a comma -deprecated-modules=optparse,tkinter.tix - -# Create a graph of external dependencies in the given file (report RP0402 must -# not be disabled) -ext-import-graph= - -# Create a graph of every (i.e. internal and external) dependencies in the -# given file (report RP0402 must not be disabled) -import-graph= - -# Create a graph of internal dependencies in the given file (report RP0402 must -# not be disabled) -int-import-graph= - -# Force import order to recognize a module as part of the standard -# compatibility libraries. -known-standard-library= - -# Force import order to recognize a module as part of a third party library. -known-third-party=enchant - - -[EXCEPTIONS] - -# Exceptions that will emit a warning when being caught. Defaults to -# "Exception" -overgeneral-exceptions= diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index 3f3993c8..00000000 --- a/mypy.ini +++ /dev/null @@ -1,20 +0,0 @@ -[mypy] -check_untyped_defs = True -disallow_any_generics = True -disallow_any_unimported = True -disallow_incomplete_defs = True -disallow_subclassing_any = True -;disallow_untyped_calls = True -disallow_untyped_decorators = True -disallow_untyped_defs = True -no_implicit_optional = True -no_implicit_reexport = True -show_error_codes = True -strict_concatenate = True -strict_equality = True -warn_redundant_casts = True -warn_return_any = True -warn_unused_configs = True -warn_unused_ignores = True -mypy_path = ./maintenance_scripts/mypy_stubs -;enable_incomplete_feature = Unpack diff --git a/oomox_gui/color.py b/oomox_gui/color.py index 4052c1a1..b102f791 100644 --- a/oomox_gui/color.py +++ b/oomox_gui/color.py @@ -74,9 +74,9 @@ def hex_darker(color_text: "HexColor", darken_amount: int = 10) -> "HexColor": class ColorDiff: - r: int # pylint: disable=invalid-name - g: int # pylint: disable=invalid-name - b: int # pylint: disable=invalid-name + r: int + g: int + b: int @property def color_list(self) -> "IntColor": diff --git a/oomox_gui/main.py b/oomox_gui/main.py index c528f6e8..fb521cd3 100755 --- a/oomox_gui/main.py +++ b/oomox_gui/main.py @@ -142,7 +142,7 @@ class WindowActions(ActionsEnum): show_about = ActionProperty(_target, "show_about") -class OomoxApplicationWindow(WindowWithActions): # pylint: disable=too-many-instance-attributes,too-many-public-methods +class OomoxApplicationWindow(WindowWithActions): # pylint: disable=too-many-instance-attributes colorscheme_name: str colorscheme_path: str diff --git a/pyproject.toml b/pyproject.toml index ede5b09a..efccf513 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,6 +8,26 @@ max_line_length = 120 ignore = "" aggressive = 1 +[tool.mypy] +check_untyped_defs = true +disallow_any_generics = true +disallow_any_unimported = true +disallow_incomplete_defs = true +disallow_subclassing_any = true +#disallow_untyped_calls = true +disallow_untyped_decorators = true +disallow_untyped_defs = true +no_implicit_optional = true +no_implicit_reexport = true +show_error_codes = true +extra_checks = true +strict_equality = true +warn_redundant_casts = true +warn_return_any = true +warn_unused_configs = true +warn_unused_ignores = true +mypy_path = './maintenance_scripts/mypy_stubs' + [tool.ruff] line-length = 120 unsafe-fixes = true @@ -136,8 +156,119 @@ ignore = [ "T201", ] "maintenance_scripts/pikaman.py" = [ - "ARG002", + "ARG002", + "PLR6301", + "PLR0904", ] "maintenance_scripts/vulture_whitelist.py" = [ - "B018", + "B018", + "SLF001", ] + +[tool.pylint.MASTER] +#jobs = '0' # multi-proc pylint doesn't work with gi/gtk stuff +jobs = '1' +extension-pkg-whitelist = 'pyalpm' +ignore = 'CVS,ignoreme.py' +ignore-patterns = '' +persistent = 'yes' +unsafe-load-any-extension = 'no' +load-plugins = 'pylint.extensions.docparams,' + +[tool.pylint.PARAMETER_DOCUMENTATION] +accept-no-param-doc = 'no' +accept-no-raise-doc = 'no' +accept-no-return-doc = 'no' +accept-no-yields-doc = 'no' + +[tool.pylint.'MESSAGES CONTROL'] +confidence = '' +disable = 'too-few-public-methods,missing-docstring,duplicate-code,missing-return-doc,missing-param-doc,missing-yield-doc,missing-raises-doc,,too-many-nested-blocks,too-many-public-methods,too-many-arguments,too-many-locals' +enable = 'useless-suppression' + +[tool.pylint.REPORTS] +evaluation = '10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)' +output-format = 'text' +reports = 'no' +score = 'yes' + +[tool.pylint.REFACTORING] +max-nested-blocks = '5' + +[tool.pylint.FORMAT] +expected-line-ending-format = 'LF' +ignore-long-lines = '^\s*(# )??$' +indent-after-paren = '4' +indent-string = ' ' +max-line-length = '120' +max-module-lines = '1000' +single-line-if-stmt = 'no' + +[tool.pylint.TYPECHECK] +contextmanager-decorators = 'contextlib.contextmanager' +generated-members = 'self.props' +ignored-classes = 'optparse.Values,thread._local,_thread._local' +ignored-modules = '' +missing-member-hint = 'yes' +missing-member-hint-distance = '1' +missing-member-max-choices = '1' + +[tool.pylint.SIMILARITIES] +ignore-comments = 'yes' +ignore-docstrings = 'yes' +ignore-imports = 'no' +min-similarity-lines = '4' + +[tool.pylint.LOGGING] +logging-modules = 'logging' +logging-format-style = 'new' + +[tool.pylint.VARIABLES] +additional-builtins = '_' +allow-global-unused-variables = 'yes' +callbacks = 'cb_,_cb' +dummy-variables-rgx = '_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy' +ignored-argument-names = '_.*' +init-import = 'no' +redefining-builtins-modules = 'six.moves,future.builtins' + +[tool.pylint.MISCELLANEOUS] +notes = 'FIXME,XXX' + +[tool.pylint.BASIC] +argument-rgx = '(([a-z][a-z0-9_]{2,40})|(_[a-z0-9_]*))$' +attr-rgx = '(([a-z][a-z0-9_]{2,40})|(_[a-z0-9_]*))$' +bad-names = 'foo,bar,baz,toto,tutu,tata' +class-attribute-rgx = '([A-Za-z_][A-Za-z0-9_]{2,40}|(__.*__)|r|g|b)$' +class-rgx = '[A-Z_][a-zA-Z0-9]+$' +const-rgx = '(([A-Z_][A-Z0-9_]*)|(__.*__))$' +docstring-min-length = '-1' +function-rgx = '(([a-z][a-z0-9_]{2,40})|(_[a-z0-9_]*))$' +good-names = 'i,j,k,ex,Run,_' +include-naming-hint = 'no' +inlinevar-rgx = '[A-Za-z_][A-Za-z0-9_]*$' +method-rgx = '(([a-z][a-z0-9_]{2,40})|(_[a-z0-9_]*))$' +module-rgx = '(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$' +name-group = '' +no-docstring-rgx = '^_' +property-classes = 'abc.abstractproperty' +variable-rgx = '(([a-z][a-z0-9_]{2,40})|(_[a-z0-9_]*)|r|g|b)$' + +[tool.pylint.CLASSES] +defining-attr-methods = '__init__,__new__,setUp,__enter__' +exclude-protected = '_asdict,_fields,_replace,_source,_make' + +[tool.pylint.DESIGN] +max-args = '5' +max-attributes = '20' +max-bool-expr = '6' +max-branches = '12' +max-locals = '15' +max-parents = '7' +max-public-methods = '20' +max-returns = '6' +max-statements = '50' +min-public-methods = '2' + +[tool.pylint.EXCEPTIONS] +overgeneral-exceptions = ''