From 7d1d7fa928674b317466629abfccef9b82b1677e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Such=C3=A1nek?= Date: Tue, 9 Jul 2024 14:46:17 +0200 Subject: [PATCH] chore: Improve code style checks --- .github/workflows/code-style.yml | 76 ++- .github/workflows/test.yml | 2 +- .pylintrc.ini | 637 ++++++++++++++++++ packages/dsw-command-queue/pyproject.toml | 4 +- packages/dsw-config/dsw/config/parser.py | 9 +- packages/dsw-config/pyproject.toml | 4 +- .../dsw/data_seeder/context.py | 21 +- packages/dsw-data-seeder/pyproject.toml | 4 +- packages/dsw-database/pyproject.toml | 4 +- .../dsw/document_worker/context.py | 21 +- .../dsw/document_worker/templates/filters.py | 9 +- .../document_worker/templates/steps/excel.py | 17 +- .../templates/steps/template.py | 11 +- .../document_worker/templates/steps/word.py | 12 +- .../document_worker/templates/templates.py | 14 +- .../dsw/document_worker/worker.py | 22 +- packages/dsw-document-worker/pyproject.toml | 4 +- packages/dsw-mailer/dsw/mailer/cli.py | 11 +- packages/dsw-mailer/dsw/mailer/context.py | 17 +- packages/dsw-mailer/dsw/mailer/templates.py | 2 +- packages/dsw-mailer/pyproject.toml | 4 +- packages/dsw-models/dsw/models/km/events.py | 97 ++- packages/dsw-models/dsw/models/km/package.py | 8 +- packages/dsw-models/pyproject.toml | 4 +- packages/dsw-storage/pyproject.toml | 4 +- packages/dsw-tdk/pyproject.toml | 4 +- 26 files changed, 851 insertions(+), 171 deletions(-) create mode 100644 .pylintrc.ini diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml index 951d86f0..86885841 100644 --- a/.github/workflows/code-style.yml +++ b/.github/workflows/code-style.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.11 + python-version: 3.12 cache: pip cache-dependency-path: | **/pyproject.toml @@ -26,10 +26,10 @@ jobs: run: | bash scripts/build-info.sh - - name: Install Flake8 (5.0.4) + - name: Install Flake8 (7.1.0) run: | python -m pip install --upgrade pip - pip install flake8==5.0.4 + pip install flake8==7.1.0 - name: Install dependencies run: | @@ -51,6 +51,7 @@ jobs: echo "- $package" echo "-------------------------------------------------" pip install packages/$package + rm -rf packages/$package/build echo "=================================================" done @@ -71,7 +72,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.11 + python-version: 3.12 cache: pip cache-dependency-path: | **/pyproject.toml @@ -81,10 +82,10 @@ jobs: run: | bash scripts/build-info.sh - - name: Install MyPy (1.4.1) + - name: Install MyPy (1.11.2) run: | python -m pip install --upgrade pip - pip install mypy==1.4.1 + pip install mypy==1.11.2 - name: Install dependencies run: | @@ -106,14 +107,18 @@ jobs: echo "- $package" echo "-------------------------------------------------" pip install packages/$package + rm -rf packages/$package/build echo "=================================================" done - name: Check typing with MyPy run: | - mypy --install-types --ignore-missing-imports --check-untyped-defs --non-interactive packages/*/dsw - + mkdir -p .mypy_cache + mypy --install-types --ignore-missing-imports \ + --check-untyped-defs --non-interactive \ + packages/*/dsw + # Consistency of version tagging version: name: Version consts.py runs-on: ubuntu-latest @@ -145,3 +150,58 @@ jobs: bash scripts/check-version.sh \ packages/dsw-tdk/dsw/tdk/consts.py \ packages/dsw-tdk/pyproject.toml + + # Pylint + pylint: + name: Pylint + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.12 + cache: pip + cache-dependency-path: | + **/pyproject.toml + **/requirements*.txt + + - name: Create build info + run: | + bash scripts/build-info.sh + + - name: Install PyLint (3.2.5) + run: | + python -m pip install --upgrade pip + pip install pylint==3.2.5 + + - name: Install dependencies + run: | + ROOT=$(pwd) + for package in $(ls packages); do + echo "-------------------------------------------------" + echo "- $package" + echo "-------------------------------------------------" + cd "$ROOT/packages/$package" + pip install -r requirements.txt + make local-deps + echo "=================================================" + done + + - name: Install packages + run: | + for package in $(ls packages); do + echo "-------------------------------------------------" + echo "- $package" + echo "-------------------------------------------------" + pip install packages/$package + rm -rf packages/$package/build + echo "=================================================" + done + + - name: Lint with PyLint + run: | + pylint --rcfile=.pylintrc.ini packages/*/dsw diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 52007c66..4463f6a4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,8 +15,8 @@ jobs: - 'ubuntu-latest' - 'windows-latest' python-version: - - '3.10' - '3.11' + - '3.12' runs-on: ${{ matrix.os }} diff --git a/.pylintrc.ini b/.pylintrc.ini new file mode 100644 index 00000000..6af53fca --- /dev/null +++ b/.pylintrc.ini @@ -0,0 +1,637 @@ +[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= + +# 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 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, and will cap the count on Windows to +# avoid hangs. +jobs=1 + +# Control the amount of potential inferred values when inferring a single +# object. This can help the performance when dealing with large functions or +# complex, nested conditions. +limit-inference-results=100 + +# List of plugins (as comma separated values of python module names) to load, +# usually to register additional checkers. +load-plugins= + +# Pickle collected data for later comparisons. +persistent=yes + +# Minimum Python version to use for version dependent checks. Will default to +# the version used to run pylint. +py-version=3.11 + +# 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 + +# Allow loading of arbitrary C extensions. Extensions are imported into the +# active Python interpreter and may run arbitrary code. +unsafe-load-any-extension=no + +# In verbose mode, extra non-checker-related info will be displayed. +#verbose= + + +[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= + +# 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=-1 + +# 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, + db, + s3, + 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 + +# 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= + +# Naming style matching correct method names. +method-naming-style=snake_case + +# 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= + +# 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= + +# 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. +# 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. If left empty, variable names will be checked with the set +# naming style. +#variable-rgx= + + +[CLASSES] + +# Warn about protected attribute access inside special methods +check-protected-access-in-special-methods=no + +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__, + __new__, + setUp, + asyncSetUp, + __post_init__ + +# List of member names, which should be excluded from the protected access +# warning. +exclude-protected=_asdict,_fields,_replace,_source,_make,os._exit + +# 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] + +# List of regular expressions of class ancestor names to ignore when counting +# public methods (see R0903) +exclude-too-few-public-methods= + +# List of qualified class names to ignore when counting class parents (see +# R0901) +ignored-parents= + +# Maximum number of arguments for function / method. +max-args=5 + +# Maximum number of attributes for a class (see R0902). +max-attributes=7 + +# Maximum number of boolean expressions in an if statement (see R0916). +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 + + +[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] + +# List of modules that can be imported at any level, not just the top level +# 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 + +# Deprecated modules which should not be used, separated by a comma. +deprecated-modules= + +# 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= + +# 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= + +# 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 +# compatibility libraries. +known-standard-library= + +# Force import order to recognize a module as part of a third party library. +known-third-party=enchant + +# Couples of modules and preferred modules, separated by a comma. +preferred-modules= + + +[LOGGING] + +# The type of string formatting that logging methods do. `old` means using % +# formatting, `new` is for `{}` formatting. +logging-format-style=old + +# Logging modules to check that the string format arguments are in logging +# function parameter format. +logging-modules=logging + + +[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 + +# 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-symbolic-message-instead, + missing-function-docstring, + missing-module-docstring, + missing-class-docstring, + broad-exception-caught + +# 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 + + +[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, json +# 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/packages/dsw-command-queue/pyproject.toml b/packages/dsw-command-queue/pyproject.toml index 1ed6c522..8fae6b71 100644 --- a/packages/dsw-command-queue/pyproject.toml +++ b/packages/dsw-command-queue/pyproject.toml @@ -16,13 +16,13 @@ classifiers = [ 'Development Status :: 5 - Production/Stable', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', - 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Topic :: Database', 'Topic :: Text Processing', 'Topic :: Utilities', ] -requires-python = '>=3.10, <4' +requires-python = '>=3.11, <4' dependencies = [ 'func-timeout', # DSW diff --git a/packages/dsw-config/dsw/config/parser.py b/packages/dsw-config/dsw/config/parser.py index b0a042a0..45ea9b36 100644 --- a/packages/dsw-config/dsw/config/parser.py +++ b/packages/dsw-config/dsw/config/parser.py @@ -1,8 +1,7 @@ import os +import typing import yaml -from typing import List, Any, IO - from .keys import ConfigKey, ConfigKeys from .model import GeneralConfig, SentryConfig, S3Config, \ DatabaseConfig, LoggingConfig, CloudConfig, AWSConfig @@ -10,7 +9,7 @@ class MissingConfigurationError(Exception): - def __init__(self, missing: List[str]): + def __init__(self, missing: list[str]): self.missing = missing @@ -28,7 +27,7 @@ def can_read(content: str): except Exception: return False - def read_file(self, fp: IO): + def read_file(self, fp: typing.IO): self.cfg = yaml.load(fp, Loader=yaml.FullLoader) or self.cfg def read_string(self, content: str): @@ -55,7 +54,7 @@ def has_value_for_key(self, key: ConfigKey): return True def get_or_default(self, key: ConfigKey): - x = self.cfg # type: Any + x: typing.Any = self.cfg for p in key.yaml_path: if not hasattr(x, 'keys') or p not in x.keys(): return key.default diff --git a/packages/dsw-config/pyproject.toml b/packages/dsw-config/pyproject.toml index aba4eac9..158dd99a 100644 --- a/packages/dsw-config/pyproject.toml +++ b/packages/dsw-config/pyproject.toml @@ -16,12 +16,12 @@ classifiers = [ 'Development Status :: 5 - Production/Stable', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', - 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Topic :: Text Processing', 'Topic :: Utilities', ] -requires-python = '>=3.10, <4' +requires-python = '>=3.11, <4' dependencies = [ 'PyYAML', 'sentry-sdk', diff --git a/packages/dsw-data-seeder/dsw/data_seeder/context.py b/packages/dsw-data-seeder/dsw/data_seeder/context.py index b8307fd1..d7a8a7b3 100644 --- a/packages/dsw-data-seeder/dsw/data_seeder/context.py +++ b/packages/dsw-data-seeder/dsw/data_seeder/context.py @@ -1,11 +1,9 @@ import pathlib -from typing import Optional, TYPE_CHECKING +from dsw.database import Database +from dsw.storage import S3Storage -if TYPE_CHECKING: - from .config import SeederConfig - from dsw.database import Database - from dsw.storage import S3Storage +from .config import SeederConfig class ContextNotInitializedError(RuntimeError): @@ -16,11 +14,12 @@ def __init__(self): class AppContext: - def __init__(self, db, s3, cfg, workdir): - self.db = db # type: Database - self.s3 = s3 # type: S3Storage - self.cfg = cfg # type: SeederConfig - self.workdir = workdir # type: pathlib.Path + def __init__(self, db: Database, s3: S3Storage, + cfg: SeederConfig, workdir: pathlib.Path): + self.db = db # type: + self.s3 = s3 # type: + self.cfg = cfg + self.workdir = workdir class JobContext: @@ -49,7 +48,7 @@ def reset_ids(self): class Context: - _instance = None # type: Optional[_Context] + _instance: _Context | None = None @classmethod def get(cls) -> _Context: diff --git a/packages/dsw-data-seeder/pyproject.toml b/packages/dsw-data-seeder/pyproject.toml index 872961ea..b6ac4882 100644 --- a/packages/dsw-data-seeder/pyproject.toml +++ b/packages/dsw-data-seeder/pyproject.toml @@ -16,13 +16,13 @@ classifiers = [ 'Development Status :: 5 - Production/Stable', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', - 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Topic :: Database', 'Topic :: Text Processing', 'Topic :: Utilities', ] -requires-python = '>=3.10, <4' +requires-python = '>=3.11, <4' dependencies = [ 'click', 'python-dateutil', diff --git a/packages/dsw-database/pyproject.toml b/packages/dsw-database/pyproject.toml index 4979d4ce..5c2d5c5c 100644 --- a/packages/dsw-database/pyproject.toml +++ b/packages/dsw-database/pyproject.toml @@ -16,12 +16,12 @@ classifiers = [ 'Development Status :: 5 - Production/Stable', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', - 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Topic :: Database', 'Topic :: Utilities', ] -requires-python = '>=3.10, <4' +requires-python = '>=3.11, <4' dependencies = [ 'psycopg[binary]', 'tenacity', diff --git a/packages/dsw-document-worker/dsw/document_worker/context.py b/packages/dsw-document-worker/dsw/document_worker/context.py index 2862dfcc..130de901 100644 --- a/packages/dsw-document-worker/dsw/document_worker/context.py +++ b/packages/dsw-document-worker/dsw/document_worker/context.py @@ -1,11 +1,9 @@ import pathlib -from typing import Optional, TYPE_CHECKING +from dsw.database import Database +from dsw.storage import S3Storage -if TYPE_CHECKING: - from .config import DocumentWorkerConfig - from dsw.database import Database - from dsw.storage import S3Storage +from .config import DocumentWorkerConfig class ContextNotInitializedError(RuntimeError): @@ -16,11 +14,12 @@ def __init__(self): class AppContext: - def __init__(self, db, s3, cfg, workdir): - self.db = db # type: Database - self.s3 = s3 # type: S3Storage - self.cfg = cfg # type: DocumentWorkerConfig - self.workdir = workdir # type: pathlib.Path + def __init__(self, db: Database, s3: S3Storage, cfg: DocumentWorkerConfig, + workdir: pathlib.Path): + self.db = db + self.s3 = s3 + self.cfg = cfg + self.workdir = workdir class JobContext: @@ -49,7 +48,7 @@ def reset_ids(self): class Context: - _instance = None # type: Optional[_Context] + _instance: _Context | None = None @classmethod def get(cls) -> _Context: diff --git a/packages/dsw-document-worker/dsw/document_worker/templates/filters.py b/packages/dsw-document-worker/dsw/document_worker/templates/filters.py index 1f53547d..3b2c430f 100644 --- a/packages/dsw-document-worker/dsw/document_worker/templates/filters.py +++ b/packages/dsw-document-worker/dsw/document_worker/templates/filters.py @@ -5,8 +5,7 @@ import markupsafe import markdown import re - -from typing import Any, Union, Optional +import typing from ..exceptions import JobException from ..model import DocumentContext @@ -76,12 +75,12 @@ def get_template(self, template_str: str) -> jinja2.Template: _alphabet_size = len(_alphabet) _base_jinja_loader = jinja2.BaseLoader() _j2_env = _JinjaEnv() -_empty_dict = dict() # type: dict[str, Any] +_empty_dict: dict[str, typing.Any] = dict() _romans = [(1000, 'M'), (900, 'CM'), (500, 'D'), (400, 'CD'), (100, 'C'), (90, 'XC'), (50, 'L'), (40, 'XL'), (10, 'X'), (9, 'IX'), (5, 'V'), (4, 'IV'), (1, 'I')] -def datetime_format(iso_timestamp: Union[None, datetime.datetime, str], fmt: str): +def datetime_format(iso_timestamp: None | datetime.datetime | str, fmt: str): if iso_timestamp is None: return '' if not isinstance(iso_timestamp, datetime.datetime): @@ -133,7 +132,7 @@ def _has_value(reply: dict) -> bool: return bool(reply) and ('value' in reply.keys()) and ('value' in reply['value'].keys()) -def _get_value(reply: dict) -> Any: +def _get_value(reply: dict) -> typing.Any: return reply['value']['value'] diff --git a/packages/dsw-document-worker/dsw/document_worker/templates/steps/excel.py b/packages/dsw-document-worker/dsw/document_worker/templates/steps/excel.py index 1f9032af..1a63ef8e 100644 --- a/packages/dsw-document-worker/dsw/document_worker/templates/steps/excel.py +++ b/packages/dsw-document-worker/dsw/document_worker/templates/steps/excel.py @@ -4,20 +4,19 @@ import io import json import pathlib +import typing import xlsxwriter from xlsxwriter.chart import Chart from xlsxwriter.format import Format from xlsxwriter.worksheet import Worksheet -from typing import Any - from ...documents import DocumentFile, FileFormats from .base import Step, register_step, TMP_DIR, FormatStepException -_EMPTY_DICT = {} # type: dict[str, Any] -_EMPTY_LIST = [] # type: list[Any] +_EMPTY_DICT: dict[str, typing.Any] = {} +_EMPTY_LIST: list[typing.Any] = [] def _b64img2io(b64bytes: str) -> io.BytesIO: @@ -115,9 +114,9 @@ class WorkbookBuilder: def __init__(self, workbook: xlsxwriter.Workbook): self.workbook = workbook - self.sheets = list() # type: list[Worksheet] - self.formats = dict() # type: dict[str, Format] - self.charts = dict() # type: dict[str, Chart] + self.sheets: list[Worksheet] = list() + self.formats: dict[str, Format] = dict() + self.charts: dict[str, Chart] = dict() def _add_workbook_options(self, data: dict): # customized options not in regular 'constructor options' @@ -501,7 +500,7 @@ def _fix_footer_header_images(options): @classmethod def _setup_worksheet_common(cls, worksheet: Worksheet, data: dict): - data = data.get('options', None) + data: dict | None = data.get('options', None) if data is None: return if data.get('select', False): @@ -524,7 +523,7 @@ def _setup_worksheet_common(cls, worksheet: Worksheet, data: dict): cls._setup_worksheet_print(worksheet, data) def _setup_worksheet_data(self, worksheet: Worksheet, data: dict): - data = data.get('options', None) + data: dict | None = data.get('options', None) if data is None: return self._setup_worksheet_basic(worksheet, data) diff --git a/packages/dsw-document-worker/dsw/document_worker/templates/steps/template.py b/packages/dsw-document-worker/dsw/document_worker/templates/steps/template.py index 8ac5e38c..a889d6b7 100644 --- a/packages/dsw-document-worker/dsw/document_worker/templates/steps/template.py +++ b/packages/dsw-document-worker/dsw/document_worker/templates/steps/template.py @@ -1,11 +1,10 @@ -import typing as t +import typing import jinja2 import jinja2.exceptions import jinja2.sandbox import json -from typing import Any from ...consts import DEFAULT_ENCODING from ...context import Context @@ -30,7 +29,7 @@ def execute_follow(self, document: DocumentFile, context: dict) -> DocumentFile: class JinjaEnvironment(jinja2.sandbox.SandboxedEnvironment): - def is_safe_attribute(self, obj: t.Any, attr: str, value: t.Any) -> bool: + def is_safe_attribute(self, obj: typing.Any, attr: str, value: typing.Any) -> bool: if attr in ['os', 'subprocess', 'eval', 'exec', 'popen', 'system']: return False if attr == '__setitem__' and isinstance(obj, dict): @@ -94,13 +93,13 @@ def __init__(self, template, options: dict): def _apply_policies(self, options: dict): # https://jinja.palletsprojects.com/en/3.0.x/api/#policies - policies = { + policies: dict[str, typing.Any] = { 'policy.urlize.target': '_blank', 'json.dumps_kwargs': { 'allow_nan': False, 'ensure_ascii': False, }, - } # type: dict[str,Any] + } if 'policy.truncate.leeway' in options: policies['truncate.leeway'] = options['policy.truncate.leeway'] if 'policy.urlize.rel' in options: @@ -151,7 +150,7 @@ def _add_j2_enhancements(self): ) self.j2_env.globals.update({'rdflib': rdflib, 'json': json}) if template_cfg is not None: - global_vars = {'secrets': template_cfg.secrets} # type: dict[str,Any] + global_vars: dict[str, typing.Any] = {'secrets': template_cfg.secrets} if template_cfg.requests.enabled: global_vars['requests'] = RequestsWrapper( template_cfg=template_cfg, diff --git a/packages/dsw-document-worker/dsw/document_worker/templates/steps/word.py b/packages/dsw-document-worker/dsw/document_worker/templates/steps/word.py index 657584a8..f9146459 100644 --- a/packages/dsw-document-worker/dsw/document_worker/templates/steps/word.py +++ b/packages/dsw-document-worker/dsw/document_worker/templates/steps/word.py @@ -1,10 +1,9 @@ import pathlib import jinja2 import shutil +import typing import zipfile -from typing import Any, Optional - from ...consts import DEFAULT_ENCODING from ...context import Context from ...documents import DocumentFile, FileFormats @@ -53,7 +52,7 @@ def _add_j2_enhancements(self): self.template.template_id, ) if template_cfg is not None: - global_vars = {'secrets': template_cfg.secrets} # type: dict[str, Any] + global_vars: dict[str, typing.Any] = {'secrets': template_cfg.secrets} if template_cfg.requests.enabled: global_vars['requests'] = RequestsWrapper( template_cfg=template_cfg, @@ -61,7 +60,7 @@ def _add_j2_enhancements(self): self.j2_env.globals.update(global_vars) def _render_rewrite(self, rewrite_template: str, context: dict, - existing_content: Optional[str]) -> str: + existing_content: str | None) -> str: try: j2_template = self.j2_env.get_template(rewrite_template) return j2_template.render( @@ -76,13 +75,14 @@ def _render_rewrite(self, rewrite_template: str, context: dict, def _static_rewrite(self, rewrite_file: str) -> str: try: - path = self.template.template_dir / rewrite_file # type: pathlib.Path + path: pathlib.Path = self.template.template_dir / rewrite_file return path.read_text(encoding=DEFAULT_ENCODING) except Exception as e: self.raise_exc(f'Failed loading Jinja2 template: {e}') return '' - def _get_rewrite(self, rewrite: str, context: dict, existing_content: Optional[str]) -> str: + def _get_rewrite(self, rewrite: str, context: dict, + existing_content: str | None) -> str: if rewrite.startswith('static:'): return self._static_rewrite(rewrite[7:]) elif rewrite.startswith('render:'): diff --git a/packages/dsw-document-worker/dsw/document_worker/templates/templates.py b/packages/dsw-document-worker/dsw/document_worker/templates/templates.py index 32054333..ba46d5ed 100644 --- a/packages/dsw-document-worker/dsw/document_worker/templates/templates.py +++ b/packages/dsw-document-worker/dsw/document_worker/templates/templates.py @@ -4,8 +4,6 @@ import pathlib import shutil -from typing import Optional - from dsw.database.database import DBDocumentTemplate, \ DBDocumentTemplateFile, DBDocumentTemplateAsset @@ -50,9 +48,9 @@ def src_value(self): class TemplateComposite: def __init__(self, db_template, db_files, db_assets): - self.template = db_template # type: DBDocumentTemplate - self.files = db_files # type: dict[str, DBDocumentTemplateFile] - self.assets = db_assets # type: dict[str, DBDocumentTemplateAsset] + self.template: DBDocumentTemplate = db_template + self.files: dict[str, DBDocumentTemplateFile] = db_files + self.assets: dict[str, DBDocumentTemplateAsset] = db_assets class Template: @@ -64,7 +62,7 @@ def __init__(self, tenant_uuid: str, template_dir: pathlib.Path, self.last_used = datetime.datetime.now(tz=datetime.UTC) self.db_template = db_template self.template_id = self.db_template.template.id - self.formats = dict() # type: dict[str, Format] + self.formats: dict[str, Format] = dict() self.asset_prefix = f'templates/{self.db_template.template.id}' if Context.get().app.cfg.cloud.multi_tenant: self.asset_prefix = f'{self.tenant_uuid}/{self.asset_prefix}' @@ -72,7 +70,7 @@ def __init__(self, tenant_uuid: str, template_dir: pathlib.Path, def raise_exc(self, message: str): raise TemplateException(self.template_id, message) - def fetch_asset(self, file_name: str) -> Optional[Asset]: + def fetch_asset(self, file_name: str) -> Asset | None: LOG.info(f'Fetching asset "{file_name}"') file_path = self.template_dir / file_name asset = None @@ -231,7 +229,7 @@ def get(cls) -> 'TemplateRegistry': return cls._instance def __init__(self): - self._templates = dict() # type: dict[str, dict[str, Template]] + self._templates: dict[str, dict[str, Template]] = dict() def has_template(self, tenant_uuid: str, template_id: str) -> bool: return tenant_uuid in self._templates.keys() and \ diff --git a/packages/dsw-document-worker/dsw/document_worker/worker.py b/packages/dsw-document-worker/dsw/document_worker/worker.py index da15f31f..284668fb 100644 --- a/packages/dsw-document-worker/dsw/document_worker/worker.py +++ b/packages/dsw-document-worker/dsw/document_worker/worker.py @@ -4,8 +4,6 @@ import logging import pathlib -from typing import Optional - from dsw.command_queue import CommandWorker, CommandQueue from dsw.config.sentry import SentryReporter from dsw.database.database import Database @@ -49,15 +47,15 @@ class Job: def __init__(self, command: PersistentCommand, document_uuid: str): self.ctx = Context.get() - self.template = None # type: Optional[Template] - self.format = None # type: Optional[Format] - self.tenant_uuid = command.tenant_uuid # type: str - self.doc_uuid = document_uuid # type: str - self.doc_context = command.body # type: dict - self.doc = None # type: Optional[DBDocument] - self.final_file = None # type: Optional[DocumentFile] - self.tenant_config = None # type: Optional[DBTenantConfig] - self.tenant_limits = None # type: Optional[DBTenantLimits] + self.template: Template | None = None + self.format: Format | None = None + self.tenant_uuid: str = command.tenant_uuid + self.doc_uuid: str = document_uuid + self.doc_context: dict = command.body + self.doc: DBDocument | None = None + self.final_file: DocumentFile | None = None + self.tenant_config: DBTenantConfig | None = None + self.tenant_limits: DBTenantLimits | None = None @property def safe_doc(self) -> DBDocument: @@ -281,7 +279,7 @@ class DocumentWorker(CommandWorker): def __init__(self, config: DocumentWorkerConfig, workdir: pathlib.Path): self.config = config self._init_context(workdir=workdir) - self.current_job = None # type: Job | None + self.current_job: Job | None = None def _init_context(self, workdir: pathlib.Path): Context.initialize( diff --git a/packages/dsw-document-worker/pyproject.toml b/packages/dsw-document-worker/pyproject.toml index 2ac4c701..b7562930 100644 --- a/packages/dsw-document-worker/pyproject.toml +++ b/packages/dsw-document-worker/pyproject.toml @@ -17,11 +17,11 @@ classifiers = [ 'License :: OSI Approved :: Apache Software License', 'Operating System :: POSIX :: Linux', 'Programming Language :: Python', - 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Topic :: Text Processing', ] -requires-python = '>=3.10, <4' +requires-python = '>=3.11, <4' dependencies = [ 'click', 'Jinja2', diff --git a/packages/dsw-mailer/dsw/mailer/cli.py b/packages/dsw-mailer/dsw/mailer/cli.py index 52690b8a..ec789fac 100644 --- a/packages/dsw-mailer/dsw/mailer/cli.py +++ b/packages/dsw-mailer/dsw/mailer/cli.py @@ -1,8 +1,7 @@ import click # type: ignore import json import pathlib - -from typing import IO +import typing from dsw.config.parser import MissingConfigurationError @@ -32,7 +31,7 @@ def load_config_str(config_str: str) -> MailerConfig: return config -def validate_config(ctx, param, value: IO | None): +def validate_config(ctx, param, value: typing.IO | None): content = '' if value is not None: content = value.read() @@ -40,7 +39,7 @@ def validate_config(ctx, param, value: IO | None): return load_config_str(content) -def extract_message_request(ctx, param, value: IO): +def extract_message_request(ctx, param, value: typing.IO): data = json.load(value) try: return MessageRequest.load_from_file(data) @@ -74,7 +73,7 @@ def cli(ctx, config: MailerConfig, workdir: str): type=click.File('r', encoding=DEFAULT_ENCODING)) def send(ctx, msg_request: MessageRequest, config: MailerConfig): from .mailer import Mailer - mailer = ctx.obj['mailer'] # type: Mailer + mailer: Mailer = ctx.obj['mailer'] mailer.send(rq=msg_request, cfg=config.mail) @@ -82,7 +81,7 @@ def send(ctx, msg_request: MessageRequest, config: MailerConfig): @click.pass_context def run(ctx): from .mailer import Mailer - mailer = ctx.obj['mailer'] # type: Mailer + mailer: Mailer = ctx.obj['mailer'] mailer.run() diff --git a/packages/dsw-mailer/dsw/mailer/context.py b/packages/dsw-mailer/dsw/mailer/context.py index e7c6aac0..8551853e 100644 --- a/packages/dsw-mailer/dsw/mailer/context.py +++ b/packages/dsw-mailer/dsw/mailer/context.py @@ -1,13 +1,10 @@ import pathlib -from typing import TYPE_CHECKING +from dsw.database import Database +from .config import MailerConfig from .templates import TemplateRegistry -if TYPE_CHECKING: - from .config import MailerConfig - from dsw.database import Database - class ContextNotInitializedError(RuntimeError): @@ -17,10 +14,10 @@ def __init__(self): class AppContext: - def __init__(self, db, cfg, workdir): - self.db = db # type: Database - self.cfg = cfg # type: MailerConfig - self.workdir = workdir # type: pathlib.Path + def __init__(self, db: Database, cfg: MailerConfig, workdir: pathlib.Path): + self.db = db + self.cfg = cfg + self.workdir = workdir class JobContext: @@ -47,7 +44,7 @@ def reset_ids(self): class Context: - _instance = None # type: _Context | None + _instance: _Context | None = None @classmethod def get(cls) -> _Context: diff --git a/packages/dsw-mailer/dsw/mailer/templates.py b/packages/dsw-mailer/dsw/mailer/templates.py index 8f1858f2..31f9fbf4 100644 --- a/packages/dsw-mailer/dsw/mailer/templates.py +++ b/packages/dsw-mailer/dsw/mailer/templates.py @@ -11,7 +11,7 @@ from .config import MailerConfig, MailConfig from .consts import DEFAULT_ENCODING -from .model import MailMessage, MailAttachment, MessageRequest,\ +from .model import MailMessage, MailAttachment, MessageRequest, \ TemplateDescriptor, TemplateDescriptorPart diff --git a/packages/dsw-mailer/pyproject.toml b/packages/dsw-mailer/pyproject.toml index a10f680f..13621bd9 100644 --- a/packages/dsw-mailer/pyproject.toml +++ b/packages/dsw-mailer/pyproject.toml @@ -16,12 +16,12 @@ classifiers = [ 'Development Status :: 5 - Production/Stable', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', - 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Topic :: Communications :: Email', 'Topic :: Text Processing', ] -requires-python = '>=3.10, <4' +requires-python = '>=3.11, <4' dependencies = [ 'boto3', 'click', diff --git a/packages/dsw-models/dsw/models/km/events.py b/packages/dsw-models/dsw/models/km/events.py index ca83c13f..444dcac3 100644 --- a/packages/dsw-models/dsw/models/km/events.py +++ b/packages/dsw-models/dsw/models/km/events.py @@ -1,10 +1,9 @@ import abc - -from typing import Generic, Optional, TypeVar, Any +import typing # https://github.com/ds-wizard/engine-backend/blob/develop/engine-shared/src/Shared/Model/Event/ -T = TypeVar('T') +T = typing.TypeVar('T') class MetricMeasure: @@ -30,9 +29,9 @@ def from_dict(data: dict) -> 'MetricMeasure': ) -class EventField(Generic[T]): +class EventField(typing.Generic[T]): - def __init__(self, changed: bool, value: Optional[T]): + def __init__(self, changed: bool, value: T | None): self.changed = changed self.value = value @@ -172,7 +171,7 @@ def to_dict(self) -> dict: return result -EVENT_TYPES = {} # type: dict[str, Any] +EVENT_TYPES: dict[str, typing.Any] = {} def event_class(cls): @@ -262,7 +261,7 @@ class AddChapterEvent(_KMAddEvent): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: list[MapEntry], - title: str, text: Optional[str]): + title: str, text: str | None): super().__init__( event_uuid=event_uuid, entity_uuid=entity_uuid, @@ -302,7 +301,7 @@ class EditChapterEvent(_KMEditEvent): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: EventField[list[MapEntry]], - title: EventField[str], text: EventField[Optional[str]], + title: EventField[str], text: EventField[str | None], question_uuids: EventField[list[str]]): super().__init__( event_uuid=event_uuid, @@ -371,7 +370,7 @@ class AddQuestionEvent(_KMAddEvent, abc.ABC): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: list[MapEntry], - title: str, text: Optional[str], required_phase_uuid: Optional[str], + title: str, text: str | None, required_phase_uuid: str | None, tag_uuids: list[str]): super().__init__( event_uuid=event_uuid, @@ -418,7 +417,7 @@ class AddOptionsQuestionEvent(AddQuestionEvent): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: list[MapEntry], - title: str, text: Optional[str], required_phase_uuid: Optional[str], + title: str, text: str | None, required_phase_uuid: str | None, tag_uuids: list[str]): super().__init__( event_uuid=event_uuid, @@ -462,7 +461,7 @@ class AddMultiChoiceQuestionEvent(AddQuestionEvent): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: list[MapEntry], - title: str, text: Optional[str], required_phase_uuid: Optional[str], + title: str, text: str | None, required_phase_uuid: str | None, tag_uuids: list[str]): super().__init__( event_uuid=event_uuid, @@ -506,7 +505,7 @@ class AddListQuestionEvent(AddQuestionEvent): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: list[MapEntry], - title: str, text: Optional[str], required_phase_uuid: Optional[str], + title: str, text: str | None, required_phase_uuid: str | None, tag_uuids: list[str]): super().__init__( event_uuid=event_uuid, @@ -550,7 +549,7 @@ class AddValueQuestionEvent(AddQuestionEvent): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: list[MapEntry], - title: str, text: Optional[str], required_phase_uuid: Optional[str], + title: str, text: str | None, required_phase_uuid: str | None, tag_uuids: list[str], value_type: str): super().__init__( event_uuid=event_uuid, @@ -597,7 +596,7 @@ class AddIntegrationQuestionEvent(AddQuestionEvent): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: list[MapEntry], - title: str, text: Optional[str], required_phase_uuid: Optional[str], + title: str, text: str | None, required_phase_uuid: str | None, tag_uuids: list[str], integration_uuid: str, props: dict[str, str]): super().__init__( event_uuid=event_uuid, @@ -648,8 +647,8 @@ class EditQuestionEvent(_KMEditEvent, abc.ABC): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: EventField[list[MapEntry]], - title: EventField[str], text: EventField[Optional[str]], - required_phase_uuid: EventField[Optional[str]], + title: EventField[str], text: EventField[str | None], + required_phase_uuid: EventField[str | None], tag_uuids: EventField[list[str]], expert_uuids: EventField[list[str]], reference_uuids: EventField[list[str]]): super().__init__( @@ -701,8 +700,8 @@ class EditOptionsQuestionEvent(EditQuestionEvent): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: EventField[list[MapEntry]], - title: EventField[str], text: EventField[Optional[str]], - required_phase_uuid: EventField[Optional[str]], + title: EventField[str], text: EventField[str | None], + required_phase_uuid: EventField[str | None], tag_uuids: EventField[list[str]], expert_uuids: EventField[list[str]], reference_uuids: EventField[list[str]], answer_uuids: EventField[list[str]]): @@ -758,8 +757,8 @@ class EditMultiChoiceQuestionEvent(EditQuestionEvent): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: EventField[list[MapEntry]], - title: EventField[str], text: EventField[Optional[str]], - required_phase_uuid: EventField[Optional[str]], + title: EventField[str], text: EventField[str | None], + required_phase_uuid: EventField[str | None], tag_uuids: EventField[list[str]], expert_uuids: EventField[list[str]], reference_uuids: EventField[list[str]], choice_uuids: EventField[list[str]]): @@ -815,8 +814,8 @@ class EditListQuestionEvent(EditQuestionEvent): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: EventField[list[MapEntry]], - title: EventField[str], text: EventField[Optional[str]], - required_phase_uuid: EventField[Optional[str]], + title: EventField[str], text: EventField[str | None], + required_phase_uuid: EventField[str | None], tag_uuids: EventField[list[str]], expert_uuids: EventField[list[str]], reference_uuids: EventField[list[str]], item_template_question_uuids: EventField[list[str]]): @@ -872,8 +871,8 @@ class EditValueQuestionEvent(EditQuestionEvent): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: EventField[list[MapEntry]], - title: EventField[str], text: EventField[Optional[str]], - required_phase_uuid: EventField[Optional[str]], + title: EventField[str], text: EventField[str | None], + required_phase_uuid: EventField[str | None], tag_uuids: EventField[list[str]], expert_uuids: EventField[list[str]], reference_uuids: EventField[list[str]], value_type: EventField[str]): super().__init__( @@ -928,8 +927,8 @@ class EditIntegrationQuestionEvent(EditQuestionEvent): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: EventField[list[MapEntry]], - title: EventField[str], text: EventField[Optional[str]], - required_phase_uuid: EventField[Optional[str]], + title: EventField[str], text: EventField[str | None], + required_phase_uuid: EventField[str | None], tag_uuids: EventField[list[str]], expert_uuids: EventField[list[str]], reference_uuids: EventField[list[str]], integration_uuid: EventField[str], props: EventField[dict[str, str]]): @@ -1011,7 +1010,7 @@ class AddAnswerEvent(_KMAddEvent): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: list[MapEntry], - label: str, advice: Optional[str], metric_measures: list[MetricMeasure]): + label: str, advice: str | None, metric_measures: list[MetricMeasure]): super().__init__( event_uuid=event_uuid, entity_uuid=entity_uuid, @@ -1054,7 +1053,7 @@ class EditAnswerEvent(_KMEditEvent): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: EventField[list[MapEntry]], - label: EventField[str], advice: EventField[Optional[str]], + label: EventField[str], advice: EventField[str | None], follow_up_uuids: EventField[list[str]], metric_measures: EventField[list[MetricMeasure]]): super().__init__( @@ -1673,7 +1672,7 @@ class AddTagEvent(_KMAddEvent): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: list[MapEntry], - name: str, description: Optional[str], color: str): + name: str, description: str | None, color: str): super().__init__( event_uuid=event_uuid, entity_uuid=entity_uuid, @@ -1716,7 +1715,7 @@ class EditTagEvent(_KMEditEvent): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: EventField[list[MapEntry]], - name: EventField[str], description: EventField[Optional[str]], + name: EventField[str], description: EventField[str | None], color: EventField[str]): super().__init__( event_uuid=event_uuid, @@ -1785,8 +1784,8 @@ class AddIntegrationEvent(_KMAddEvent, abc.ABC): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: list[MapEntry], - integration_id: str, name: str, props: list[str], logo: Optional[str], - item_url: Optional[str]): + integration_id: str, name: str, props: list[str], logo: str | None, + item_url: str | None): super().__init__( event_uuid=event_uuid, entity_uuid=entity_uuid, @@ -1828,10 +1827,10 @@ class AddApiIntegrationEvent(AddIntegrationEvent): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: list[MapEntry], - integration_id: str, name: str, props: list[str], logo: Optional[str], - item_url: Optional[str], rq_method: str, rq_url: str, + integration_id: str, name: str, props: list[str], logo: str | None, + item_url: str | None, rq_method: str, rq_url: str, rq_headers: list[MapEntry], rq_body: str, rq_empty_search: bool, - rs_list_field: Optional[str], rs_item_id: Optional[str], + rs_list_field: str | None, rs_item_id: str | None, rs_item_template: str): super().__init__( event_uuid=event_uuid, @@ -1901,8 +1900,8 @@ class AddWidgetIntegrationEvent(AddIntegrationEvent): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: list[MapEntry], - integration_id: str, name: str, props: list[str], logo: Optional[str], - item_url: Optional[str], widget_url: str): + integration_id: str, name: str, props: list[str], logo: str | None, + item_url: str | None, widget_url: str): super().__init__( event_uuid=event_uuid, entity_uuid=entity_uuid, @@ -1952,8 +1951,8 @@ class EditIntegrationEvent(_KMEditEvent, abc.ABC): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: EventField[list[MapEntry]], integration_id: EventField[str], name: EventField[str], - props: EventField[list[str]], logo: EventField[Optional[str]], - item_url: EventField[Optional[str]]): + props: EventField[list[str]], logo: EventField[str | None], + item_url: EventField[str | None]): super().__init__( event_uuid=event_uuid, entity_uuid=entity_uuid, @@ -1996,11 +1995,11 @@ class EditApiIntegrationEvent(EditIntegrationEvent): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: EventField[list[MapEntry]], integration_id: EventField[str], name: EventField[str], - props: EventField[list[str]], logo: EventField[Optional[str]], - item_url: EventField[Optional[str]], rq_method: EventField[str], + props: EventField[list[str]], logo: EventField[str | None], + item_url: EventField[str | None], rq_method: EventField[str], rq_url: EventField[str], rq_headers: EventField[list[MapEntry]], rq_body: EventField[str], rq_empty_search: EventField[bool], - rs_list_field: EventField[Optional[str]], rs_item_id: EventField[Optional[str]], + rs_list_field: EventField[str | None], rs_item_id: EventField[str | None], rs_item_template: EventField[str]): super().__init__( event_uuid=event_uuid, @@ -2077,8 +2076,8 @@ class EditWidgetIntegrationEvent(EditIntegrationEvent): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: EventField[list[MapEntry]], integration_id: EventField[str], name: EventField[str], - props: EventField[list[str]], logo: EventField[Optional[str]], - item_url: EventField[Optional[str]], widget_url: EventField[str]): + props: EventField[list[str]], logo: EventField[str | None], + item_url: EventField[str | None], widget_url: EventField[str]): super().__init__( event_uuid=event_uuid, entity_uuid=entity_uuid, @@ -2152,7 +2151,7 @@ class AddMetricEvent(_KMAddEvent): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: list[MapEntry], - title: str, abbreviation: Optional[str], description: Optional[str]): + title: str, abbreviation: str | None, description: str | None): super().__init__( event_uuid=event_uuid, entity_uuid=entity_uuid, @@ -2195,8 +2194,8 @@ class EditMetricEvent(_KMEditEvent): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: EventField[list[MapEntry]], - title: EventField[str], abbreviation: EventField[Optional[str]], - description: EventField[Optional[str]]): + title: EventField[str], abbreviation: EventField[str | None], + description: EventField[str | None]): super().__init__( event_uuid=event_uuid, entity_uuid=entity_uuid, @@ -2264,7 +2263,7 @@ class AddPhaseEvent(_KMAddEvent): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: list[MapEntry], - title: str, description: Optional[str]): + title: str, description: str | None): super().__init__( event_uuid=event_uuid, entity_uuid=entity_uuid, @@ -2304,7 +2303,7 @@ class EditPhaseEvent(_KMEditEvent): def __init__(self, event_uuid: str, entity_uuid: str, parent_uuid: str, created_at: str, annotations: EventField[list[MapEntry]], - title: EventField[str], description: EventField[Optional[str]]): + title: EventField[str], description: EventField[str | None]): super().__init__( event_uuid=event_uuid, entity_uuid=entity_uuid, diff --git a/packages/dsw-models/dsw/models/km/package.py b/packages/dsw-models/dsw/models/km/package.py index edc4019e..ca40b4ca 100644 --- a/packages/dsw-models/dsw/models/km/package.py +++ b/packages/dsw-models/dsw/models/km/package.py @@ -1,14 +1,12 @@ from .events import _KMEvent, Event -from typing import Optional - class Package: def __init__(self, km_id: str, org_id: str, version: str, name: str, metamodel_version: int, description: str, license: str, - readme: str, created_at: str, fork_pkg_id: Optional[str], - merge_pkg_id: Optional[str], prev_pkg_id: Optional[str]): + readme: str, created_at: str, fork_pkg_id: str | None, + merge_pkg_id: str | None, prev_pkg_id: str | None): self.km_id = km_id self.org_id = org_id self.version = version @@ -21,7 +19,7 @@ def __init__(self, km_id: str, org_id: str, version: str, name: str, self.fork_pkg_id = fork_pkg_id self.merge_pkg_id = merge_pkg_id self.prev_pkg_id = prev_pkg_id - self.events = list() # type: list[_KMEvent] + self.events: list[_KMEvent] = list() @property def id(self): diff --git a/packages/dsw-models/pyproject.toml b/packages/dsw-models/pyproject.toml index 6a9d8726..63f2db21 100644 --- a/packages/dsw-models/pyproject.toml +++ b/packages/dsw-models/pyproject.toml @@ -16,12 +16,12 @@ classifiers = [ 'Development Status :: 4 - Beta', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', - 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Topic :: Text Processing', 'Topic :: Utilities', ] -requires-python = '>=3.10, <4' +requires-python = '>=3.11, <4' dependencies = [ ] diff --git a/packages/dsw-storage/pyproject.toml b/packages/dsw-storage/pyproject.toml index 95432cac..e118613e 100644 --- a/packages/dsw-storage/pyproject.toml +++ b/packages/dsw-storage/pyproject.toml @@ -16,12 +16,12 @@ classifiers = [ 'Development Status :: 5 - Production/Stable', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', - 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Topic :: Communications :: File Sharing', 'Topic :: Utilities', ] -requires-python = '>=3.10, <4' +requires-python = '>=3.11, <4' dependencies = [ 'minio', 'tenacity', diff --git a/packages/dsw-tdk/pyproject.toml b/packages/dsw-tdk/pyproject.toml index 1faa3917..9707d124 100644 --- a/packages/dsw-tdk/pyproject.toml +++ b/packages/dsw-tdk/pyproject.toml @@ -17,13 +17,13 @@ classifiers = [ 'Development Status :: 5 - Production/Stable', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', - 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Topic :: Internet :: WWW/HTTP', 'Topic :: Utilities', ] -requires-python = '>=3.9, <4' +requires-python = '>=3.10, <4' dependencies = [ 'aiohttp', 'click',