From 73c88e79b2201a6d044674200036ed326269dae7 Mon Sep 17 00:00:00 2001 From: Florian Strzelecki Date: Sat, 11 Nov 2023 15:15:33 +0100 Subject: [PATCH 1/7] meta: fix make test and upgrade develop/build --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index e478a64..22b5f17 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ quality: flake8 test: - coverage run -m py.test -v . + coverage run -m pytest -v . coverage_report: coverage report @@ -26,9 +26,9 @@ qa: quality test coverages pylint pyroma .PHONY: develop build develop: - pip install -r requirements.txt - python setup.py develop + pip install -U -r requirements.txt + pip install -e . build: rm -rf build/ dist/ - python setup.py sdist bdist_wheel + python -m build . From e12a2ffdebc7445cff68ed106ef1526d01a7e442 Mon Sep 17 00:00:00 2001 From: Florian Strzelecki Date: Sat, 11 Nov 2023 15:16:36 +0100 Subject: [PATCH 2/7] meta: upgrade pylint --- .pylintrc | 709 ++++++++++++++++++++++++---------------- sopel_help/config.py | 1 + sopel_help/providers.py | 4 +- 3 files changed, 424 insertions(+), 290 deletions(-) diff --git a/.pylintrc b/.pylintrc index 72178ee..97a77ed 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,24 +1,77 @@ -[MASTER] +[MAIN] + +# 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 + +# 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= + +# In error mode, messages with a category besides ERROR or FATAL are +# suppressed, and no reports are done by default. Error mode is compatible with +# disabling specific errors. +#errors-only= + +# Always return a 0 (non-error) status code, even if lint errors are found. +# This is primarily useful in continuous integration scripts. +#exit-zero= # 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-allow-list= + +# 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. (This is an alternative name to extension-pkg-allow-list +# for backward compatibility.) extension-pkg-whitelist= -# Add files or directories to the blacklist. They should be base names, not -# paths. +# Return non-zero exit code if any of these messages/categories are detected, +# even if score is above --fail-under value. Syntax same as enable. Messages +# specified are enabled, while categories only check already-enabled messages. +fail-on= + +# Specify a score threshold under which the program will exit with error. +fail-under=10 + +# Interpret the stdin as a python script, whose filename needs to be passed as +# the module_or_package argument. +#from-stdin= + +# Files or directories to be skipped. 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=test_.*\.py +# 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. +ignore-paths= + +# Files or directories matching the regular expression patterns are skipped. +# The regex matches against base names, not paths. The default value ignores +# Emacs file locks +ignore-patterns=^\.# + +# 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= # Python code to execute, usually for sys.path manipulation such as # pygtk.require(). #init-hook= # Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the -# number of processors available to use. +# number of processors available to use, and will cap the count on Windows to +# avoid hangs. jobs=1 # Control the amount of potential inferred values when inferring a single @@ -33,8 +86,18 @@ load-plugins= # Pickle collected data for later comparisons. persistent=yes -# Specify a configuration file. -#rcfile= +# Minimum Python version to use for version dependent checks. Will default to +# the version used to run pylint. +py-version=3.10 + +# 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. @@ -44,155 +107,8 @@ suggestion-mode=yes # 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=raw-checker-failed, - bad-inline-option, - locally-disabled, - file-ignored, - suppressed-message, - useless-suppression, - deprecated-pragma, - use-symbolic-message-instead, - consider-using-f-string - -# 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 - - -[REPORTS] - -# Python expression which should return a score less than or equal to 10. You -# have access to the variables 'error', 'warning', 'refactor', and 'convention' -# 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=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, e.g. -# 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 - -# Complete name of functions that never returns. When checking for -# inconsistent-return-statements if a never returning function is called then -# it will be considered as an explicit return statement and no message will be -# printed. -never-returning-functions=sys.exit - - -[MISCELLANEOUS] - -# List of note tags to take in consideration, separated by a comma. -notes=FIXME, - XXX, - TODO - - -[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=4 - - -[STRING] - -# This flag controls whether the implicit-str-concat-in-sequence should -# generate a warning on implicit string concatenation in sequences defined over -# several lines. -check-str-concat-over-line-jumps=no - - -[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= - -# 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 - - -[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=100 - -# Maximum number of lines in a module. -max-module-lines=1000 - -# 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 - -# 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 +# In verbose mode, extra non-checker-related info will be displayed. +#verbose= [BASIC] @@ -201,13 +117,15 @@ single-line-if-stmt=no argument-naming-style=snake_case # Regular expression matching correct argument names. Overrides argument- -# naming-style. +# 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= @@ -219,24 +137,38 @@ bad-names=foo, 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. +# 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. +# 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= @@ -248,7 +180,8 @@ docstring-min-length=-1 function-naming-style=snake_case # Regular expression matching correct function names. Overrides function- -# naming-style. +# 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. @@ -259,6 +192,10 @@ good-names=i, 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=no @@ -266,21 +203,22 @@ include-naming-hint=no inlinevar-naming-style=any # Regular expression matching correct inline iteration names. Overrides -# inlinevar-naming-style. +# inlinevar-naming-style. If left empty, inline iteration names will be checked +# with the set naming style. #inlinevar-rgx= # Naming style matching correct method names. method-naming-style=snake_case # Regular expression matching correct method names. Overrides method-naming- -# style. +# style. If left empty, method names will be checked with the set naming style. #method-rgx= # Naming style matching correct module names. module-naming-style=snake_case # Regular expression matching correct module names. Overrides module-naming- -# style. +# style. If left empty, module names will be checked with the set naming style. #module-rgx= # Colon-delimited sets of names that determine each other's naming style when @@ -296,111 +234,55 @@ no-docstring-rgx=^_ # 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= + +# Regular expression matching correct type variable names. If left empty, type +# variable names will be checked with the set naming style. +#typevar-rgx= + # Naming style matching correct variable names. variable-naming-style=snake_case # Regular expression matching correct variable names. Overrides variable- -# naming-style. +# naming-style. If left empty, variable names will be checked with the set +# naming style. #variable-rgx= -[LOGGING] - -# Format style used to check logging format string. `old` means using % -# formatting, `new` is for `{}` formatting,and `fstr` is for f-strings. -logging-format-style=old - -# Logging modules to check that the string format arguments are in logging -# function parameter format. -logging-modules=logging - - -[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 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. Default to name -# with leading underscore. -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 - - -[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= - -# Tells whether missing members accessed in mixin class should be ignored. A -# mixin class is detected if its name ends with "mixin" (case insensitive). -ignore-mixin-members=yes - -# Tells whether to warn about missing members when the owner of the attribute -# is inferred to be None. -ignore-none=yes +[CLASSES] -# 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 +# Warn about protected attribute access inside special methods +check-protected-access-in-special-methods=no -# 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 method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__, + __new__, + setUp, + asyncSetUp, + __post_init__ -# 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= +# List of member names, which should be excluded from the protected access +# warning. +exclude-protected=_asdict,_fields,_replace,_source,_make,os._exit -# 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 +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls -# 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 +# List of valid names for the first argument in a metaclass class method. +valid-metaclass-classmethod-first-arg=mcs -# 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 -# List of decorators that change the signature of a decorated function. -signature-mutators= +[DESIGN] +# List of regular expressions of class ancestor names to ignore when counting +# public methods (see R0903) +exclude-too-few-public-methods=sopel.config.types.StaticSection -[DESIGN] +# List of qualified class names to ignore when counting class parents (see +# R0901) +ignored-parents= # Maximum number of arguments for function / method. max-args=10 @@ -430,7 +312,43 @@ max-returns=6 max-statements=50 # Minimum number of public methods for a class (see R0903). -min-public-methods=0 +min-public-methods=2 + + +[EXCEPTIONS] + +# Exceptions that will emit a warning when caught. +overgeneral-exceptions=builtins.BaseException,builtins.Exception + + +[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=100 + +# Maximum number of lines in a module. +max-module-lines=1000 + +# 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 + +# 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] @@ -439,27 +357,26 @@ min-public-methods=0 # 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 -# 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 +deprecated-modules= -# Create a graph of external dependencies in the given file (report RP0402 must -# not be disabled). +# Output a graph (.gv or any supported image format) of external dependencies +# to 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). +# Output a graph (.gv or any supported image format) of all (i.e. internal and +# external) dependencies to 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). +# Output a graph (.gv or any supported image format) of internal dependencies +# to the given file (report RP0402 must not be disabled). int-import-graph= # Force import order to recognize a module as part of the standard @@ -473,32 +390,246 @@ known-third-party=enchant preferred-modules= -[CLASSES] +[LOGGING] -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__, - __new__, - setUp, - __post_init__ +# The type of string formatting that logging methods do. `old` means using % +# formatting, `new` is for `{}` formatting. +logging-format-style=old -# List of member names, which should be excluded from the protected access -# warning. -exclude-protected=_asdict, - _fields, - _replace, - _source, - _make +# Logging modules to check that the string format arguments are in logging +# function parameter format. +logging-modules=logging -# 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=cls +[MESSAGES CONTROL] +# 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 -[EXCEPTIONS] +# 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=raw-checker-failed, + bad-inline-option, + locally-disabled, + file-ignored, + suppressed-message, + useless-suppression, + deprecated-pragma, + use-implicit-booleaness-not-comparison-to-string, + use-implicit-booleaness-not-comparison-to-zero, + use-symbolic-message-instead, + consider-using-f-string + +# 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= -# Exceptions that will emit a warning when being caught. Defaults to -# "BaseException, Exception". -overgeneral-exceptions=BaseException, - Exception + +[METHOD_ARGS] + +# 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] + +# List of note tags to take in consideration, separated by a comma. +notes=FIXME, + XXX, + TODO + +# Regular expression of note tags to take in consideration. +notes-rgx= + + +[REFACTORING] + +# Maximum number of nested blocks for function / method body +max-nested-blocks=5 + +# Complete name of functions that never returns. When checking for +# inconsistent-return-statements if a never returning function is called then +# it will be considered as an explicit return statement and no message will be +# printed. +never-returning-functions=sys.exit,argparse.parse_error + + +[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)) + +# 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, +# json2 (improved json format), json (old json format) and msvs (visual +# studio). You can also give a reporter class, e.g. +# mypackage.mymodule.MyReporterClass. +#output-format= + +# Tells whether to display a full report or only the messages. +reports=no + +# 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] + +# This flag controls whether inconsistent-quotes generates a warning when the +# character used as a quote delimiter is used inconsistently within a module. +check-quote-consistency=no + +# This flag controls whether the implicit-str-concat should generate a warning +# on implicit string concatenation in sequences defined over several lines. +check-str-concat-over-line-jumps=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= + +# Tells whether to warn about missing members when the owner of the attribute +# is inferred to be None. +ignore-none=yes + +# 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 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/sopel_help/config.py b/sopel_help/config.py index d07971e..80247a5 100644 --- a/sopel_help/config.py +++ b/sopel_help/config.py @@ -1,4 +1,5 @@ """Configuration for the help plugin.""" + from sopel import config from sopel_help.managers import manager diff --git a/sopel_help/providers.py b/sopel_help/providers.py index 65947a1..2476274 100644 --- a/sopel_help/providers.py +++ b/sopel_help/providers.py @@ -21,8 +21,10 @@ class UnknownCommand(Exception): def _post_content(*args, **kwargs): + # ensure we always timeout + timeout = kwargs.pop('timeout', 30) try: - response = requests.post(*args, **kwargs) + response = requests.post(*args, timeout=timeout, **kwargs) response.raise_for_status() except ( requests.exceptions.Timeout, From 2e2744dcf9e88aa5f81bb20f74600c458ae09ea5 Mon Sep 17 00:00:00 2001 From: Florian Strzelecki Date: Sat, 11 Nov 2023 15:31:33 +0100 Subject: [PATCH 3/7] test: assert empty lines are ignored and get 100% coverage back --- tests/test_providers_base.py | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/test_providers_base.py b/tests/test_providers_base.py index 395f0ad..9269c8a 100644 --- a/tests/test_providers_base.py +++ b/tests/test_providers_base.py @@ -286,6 +286,44 @@ def test_send_help_commands(mockbot, triggerfactory): ) +def test_send_help_command(mockbot, triggerfactory): + provider = providers.Base() + provider.setup(mockbot) + + wrapper = triggerfactory.wrapper( + mockbot, ':Test!test@example.com PRIVMSG #channel :.help test') + + test_head = 'The command test docstring.' + test_body = [ + "line 1 of body", + "", + "line 3 of body (ignore empty line 2)", + ] + test_usages = [ + "line 1 of usage", + "", + "line 3 of usage (ignore empty line 2)", + ] + provider.send_help_command( + wrapper, + wrapper._trigger, + 'test', + test_head, + test_body, + test_usages, + ) + + assert mockbot.backend.message_sent == rawlist( + "PRIVMSG #channel :Test: The help for command test is too long; " + "I'm sending it to you in a private message.", + "PRIVMSG Test :The command test docstring.", + "PRIVMSG Test :line 1 of body", + "PRIVMSG Test :line 3 of body (ignore empty line 2)", + "PRIVMSG Test :line 1 of usage", + "PRIVMSG Test :line 3 of usage (ignore empty line 2)", + ) + + def test_help_commands(mockbot, triggerfactory): provider = providers.Base() provider.setup(mockbot) From 995f708459a430d149903a4ebf034e3368e8bc7f Mon Sep 17 00:00:00 2001 From: Florian Strzelecki Date: Sat, 11 Nov 2023 17:23:50 +0100 Subject: [PATCH 4/7] meta: switch to pyproject.toml --- pyproject.toml | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ setup.cfg | 48 ----------------------------------------- setup.py | 3 --- 3 files changed, 58 insertions(+), 51 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..5518250 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,58 @@ +[build-system] +requires = ["setuptools~=63.0", "wheel"] +build-backend = "setuptools.build_meta" + +[tool.setuptools] +platforms = ["Linux x86, x86-64"] + +[tool.setuptools.packages.find] +include = ["sopel", "sopel_help.*"] +namespaces = false + +[project] +name = "sopel-help" +version = "0.5.0.dev0" +description = "Help plugin for Sopel" +maintainers = [ + { name="dgw", email="dgw@technobabbl.es" }, + { name="Florian Strzelecki", email="florian.strzelecki@gmail.com" }, +] +authors = [ + { name="dgw", email="dgw@technobabbl.es" }, + { name="Florian Strzelecki", email="florian.strzelecki@gmail.com" }, +] +readme = "README.rst" +license = { text="EFL-2.0" } +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Intended Audience :: System Administrators", + "License :: Eiffel Forum License (EFL)", + "License :: OSI Approved :: Eiffel Forum License", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Topic :: Communications :: Chat :: Internet Relay Chat", +] +requires-python = ">=3.7" +dependencies = [ + "sopel>=7.1", + "requests", +] + +[project.urls] +"Bug Tracker" = "https://github.com/sopel-irc/sopel-help/issues" +"Source" = "https://github.com/sopel-irc/sopel-help" + +[project.entry-points."sopel.plugins"] +help = "sopel_help.plugin" + +[project.entry-points."sopel_help.providers"] +base = "sopel_help.providers:Base" +local = "sopel_help.providers:LocalFile" +clbin = "sopel_help.providers:CLBinPublisher" +0x0 = "sopel_help.providers:NullPointerPublisher" +termbin = "sopel_help.providers:TermBinPublisher" diff --git a/setup.cfg b/setup.cfg index 9fefbb5..2b37387 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,51 +1,3 @@ -[metadata] -name = sopel-help -version = 0.4.0 -description = Help plugin for Sopel -keywords = sopel plugin help bot irc -long_description = file: README.rst -long_description_content_type = text/x-rst -author = Florian Strzelecki -author_email = florian.strzelecki@gmail.com -url = https://github.com/sopel-irc/sopel-help -license = Eiffel Forum License, version 2 -license_file = LICENSE.txt -platforms = Linux x86, x86-64 -classifiers = - Development Status :: 4 - Beta - Intended Audience :: Developers - Intended Audience :: System Administrators - License :: Eiffel Forum License (EFL) - License :: OSI Approved :: Eiffel Forum License - Operating System :: POSIX :: Linux - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Topic :: Communications :: Chat :: Internet Relay Chat - -[options] -python_requires = >=3.7, <4 -packages = find: -zip_safe = false -install_requires = - sopel>=7.1 - requests - -[options.packages.find] -exclude = - sopel - sopel.* - -[options.entry_points] -sopel.plugins = - help = sopel_help.plugin -sopel_help.providers = - base = sopel_help.providers:Base - local = sopel_help.providers:LocalFile - clbin = sopel_help.providers:CLBinPublisher - 0x0 = sopel_help.providers:NullPointerPublisher - termbin = sopel_help.providers:TermBinPublisher - [flake8] max-line-length = 79 exclude = .git, .eggs, __pycache__, tests/, docs/, build/, dist/ diff --git a/setup.py b/setup.py deleted file mode 100644 index 6068493..0000000 --- a/setup.py +++ /dev/null @@ -1,3 +0,0 @@ -from setuptools import setup - -setup() From c9129a0426be98f58fe22a46ab3ff3f09123565c Mon Sep 17 00:00:00 2001 From: Florian Strzelecki Date: Sat, 11 Nov 2023 18:10:02 +0100 Subject: [PATCH 5/7] ci: add github CI for tests and lint --- .github/workflows/ci.yml | 41 ++++++++++++++++++++++++++++++++++++++++ Makefile | 30 ++++++++++++++++++----------- 2 files changed, 60 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9c7f8d5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,41 @@ +--- +name: CI + +on: + push: + branches: + - master + - v[0-9]+.[0-9]+.x + pull_request: + branches: + - master + - v[0-9]+.[0-9]+.x + +jobs: + tests: + if: ${{ github.repository_owner == 'sopel-irc' }} + name: Quality & Test Suite + runs-on: ubuntu-latest + strategy: + matrix: + python-version: + - "3.7" + - "3.8" + - "3.9" + - "3.10" + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade wheel + python -m pip install --upgrade -r requirements.txt + python -m pip install -e . + - name: Lint + run: make lint + - name: Tests + run: make test diff --git a/Makefile b/Makefile index 22b5f17..d4d3f10 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,19 @@ -.PHONY: qa quality test coverages coverage_report coverage_html pylint +# Linters (check, style, and type in the future) +.PHONY: lint-check lint-style -quality: +lint-check: isort sopel_help flake8 +lint-style: + pylint sopel_help + pyroma . + +lint: lint-check lint-style + +# Tests (tests and coverage reports) +.PHONY: test coverage_report coverage_html coverages + test: coverage run -m pytest -v . @@ -15,20 +25,18 @@ coverage_html: coverages: coverage_report coverage_html -pylint: - pylint sopel_help - -pyroma: - pyroma . - -qa: quality test coverages pylint pyroma - -.PHONY: develop build +# Development cycle (local install, qa, build, and release on PyPI) +.PHONY: develop qa build develop: pip install -U -r requirements.txt pip install -e . +qa: lint-check test coverages lint-style + build: rm -rf build/ dist/ python -m build . + +release: + twine upload -r sopel-help dist/* From 64058d2d6b06c86d1be11d988e71295c4d9c2c90 Mon Sep 17 00:00:00 2001 From: Florian Strzelecki Date: Sat, 11 Nov 2023 18:19:25 +0100 Subject: [PATCH 6/7] meta: drop Python 3.7 support In an effort to support the future (i.e. Sopel 8 and modern tooling), Python 3.7 is now dropped for official support. People using Sopel 7.1 can still use the perfectly fine previous version 0.4.0 of this plugin. Since Sopel 8 drops support for Py3.7, this shouldn't be a problem for the future. --- .github/workflows/ci.yml | 1 - README.rst | 2 +- pyproject.toml | 3 +-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c7f8d5..7e9a21f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,6 @@ jobs: strategy: matrix: python-version: - - "3.7" - "3.8" - "3.9" - "3.10" diff --git a/README.rst b/README.rst index 5f414a2..01f9f8a 100644 --- a/README.rst +++ b/README.rst @@ -15,7 +15,7 @@ The recommanded way to install this plugin is to use ``pip``:: $ pip install sopel-help -Note that this plugin requires Python 3.7+ and Sopel 7.1+. +Note that this plugin requires Python 3.8+ and Sopel 7.1+. Configure ========= diff --git a/pyproject.toml b/pyproject.toml index 5518250..d8dc989 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,14 +30,13 @@ classifiers = [ "License :: Eiffel Forum License (EFL)", "License :: OSI Approved :: Eiffel Forum License", "Operating System :: POSIX :: Linux", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Topic :: Communications :: Chat :: Internet Relay Chat", ] -requires-python = ">=3.7" +requires-python = ">=3.8" dependencies = [ "sopel>=7.1", "requests", From 3b9c0d94d02944b0c92425a1fc1fc37b983002ef Mon Sep 17 00:00:00 2001 From: Florian Strzelecki Date: Sat, 27 Apr 2024 16:10:44 +0200 Subject: [PATCH 7/7] meta: upgrade pyproject.toml --- pyproject.toml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d8dc989..bf12887 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,18 +1,19 @@ [build-system] -requires = ["setuptools~=63.0", "wheel"] +requires = ["setuptools>=68.0", "wheel"] build-backend = "setuptools.build_meta" [tool.setuptools] platforms = ["Linux x86, x86-64"] [tool.setuptools.packages.find] -include = ["sopel", "sopel_help.*"] +include = ["sopel_help.*"] namespaces = false [project] name = "sopel-help" version = "0.5.0.dev0" description = "Help plugin for Sopel" +keywords = ["sopel", "irc", "help", "doc", "plugin"] maintainers = [ { name="dgw", email="dgw@technobabbl.es" }, { name="Florian Strzelecki", email="florian.strzelecki@gmail.com" }, @@ -34,6 +35,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Communications :: Chat :: Internet Relay Chat", ] requires-python = ">=3.8"