From df9087e4b820d54177433dcf647ee8f116a54c40 Mon Sep 17 00:00:00 2001 From: fstagni Date: Tue, 14 Mar 2023 14:48:10 +0100 Subject: [PATCH] sweep: #734 Fix imports from TornadoRest for UPHandler --- .pylintrc | 215 -------------------- README.rst | 4 +- pyproject.toml | 59 ++++++ src/WebAppDIRAC/WebApp/handler/UPHandler.py | 6 +- 4 files changed, 64 insertions(+), 220 deletions(-) delete mode 100644 .pylintrc diff --git a/.pylintrc b/.pylintrc deleted file mode 100644 index 0a4415aac..000000000 --- a/.pylintrc +++ /dev/null @@ -1,215 +0,0 @@ -[MASTER] -# Specify a configuration file. -#rcfile= - -# Python code to execute, usually for sys.path manipulation such as -# pygtk.require(). -# init-hook='import sys; sys.path.append("$WORKSPACE/DIRAC/WorkloadManagementSystem/PilotAgent")' - -# Add to the black list. It should be a base name, not a -# path. You may set this option multiple times. -ignore=.svn,.git - -# Pickle collected data for later comparisons. -persistent=yes - -# List of plugins (as comma separated values of python modules names) to load, -# usually to register additional checkers. -load-plugins= - - -[MESSAGES CONTROL] - -# 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. - -# Disable 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). - -#R0903 = Too few public methods (%s/%s) -#C0326 = bad-whitespace -#I0011 = locally-disabling -disable=R0903,C0326,I0011,redefined-variable-type,c-extension-no-member - - -[REPORTS] - -# Set the output format. Available formats are text, parseable, colorized, msvs -# (visual studio) and html -output-format=colorized - -# Put messages in a separate file for each module / package specified on the -# command line instead of printing them on stdout. Reports (if any) will be -# written in a file name "pylint_global.[txt|html]". -files-output=no - -# Tells whether to display a full report or only the messages -reports=no - -# Python expression which should return a note less than 10 (10 is the highest -# note). You have access to the variables errors warning, statement which -# respectively contain the number of errors / warnings messages and the total -# number of statements analyzed. This is used by the global evaluation report -# (RP0004). -evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) - -[BASIC] - -# List of builtins function names that should not be used, separated by a comma -bad-functions=map,filter,apply,input,raw_input,has_key - -# Regular expression which should only match correct module names -# Added last option, to take into account script names -module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+)|([dirac_-][a-zA-Z_-]+)|(Test_[a-zA-Z_-]+))$ - -# Regular expression which should only match correct module level names -#const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__)|(g[A-Z][a-zA-Z0-9]*))$ -const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__)|(g[A-Z][a-zA-Z0-9]*)|[a-z_][A-Za-z0-9_]*)$ - -# Regular expression which should only match correct class names -class-rgx=[A-Z_][a-zA-Z0-9]+$ - -# Regular expression which should only match correct function names -function-rgx=(([a-z_][A-Za-z0-9_]{2,30}$)|(test_[A-Za-z0-9_]{2,50}$)) - -# Regular expression which should only match correct method names -method-rgx=[a-z_][A-Za-z0-9_]{2,30}$ - -# Regular expression which should only match correct instance attribute names -attr-rgx=[a-z_][A-Za-z0-9_]{2,30}$ - -# Regular expression which should only match correct argument names -argument-rgx=[a-z_][A-Za-z0-9_]{1,30}$ - -# Regular expression which should only match correct variable names -variable-rgx=[a-z_][A-Za-z0-9_]{1,30}$ - -# Regular expression which should only match correct list comprehension / -# generator expression variable names -inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ - -# Good variable names which should always be accepted, separated by a comma -good-names=e,i,j,k,x,ex,Run,_,S_OK,S_ERROR - -# Bad variable names which should always be refused, separated by a comma -bad-names=foo,bar,baz,toto,tutu,tata,spam,egg - -# Regular expression which should only match functions or classes name which do -# not require a docstring -no-docstring-rgx=__.*__ - - -[FORMAT] - -# Maximum number of characters on a single line. -max-line-length=130 - -# Maximum number of lines in a module -max-module-lines=1200 - -[MISCELLANEOUS] - -# List of note tags to take in consideration, separated by a comma. -notes=FIXME,XXX,TODO - -[SIMILARITIES] - -# Minimum lines number of a similarity. -min-similarity-lines=4 - -# Ignore comments when computing similarities. -ignore-comments=yes - -# Ignore docstrings when computing similarities. -ignore-docstrings=yes - -[TYPECHECK] - -# 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 - -# List of classes names for which member attributes should not be checked -# (useful for classes with attributes dynamically set). -ignored-classes=SQLObject - -# List of members which are set dynamically and missed by pylint inference -# system, and so shouldn't trigger E0201 when accessed. -generated-members=REQUEST,acl_users,aq_parent - -# List of ignored modules -ignored-modules = numpy - -[VARIABLES] - -# Tells whether we should check for unused import in __init__ files. -init-import=no - -# A regular expression matching the beginning of the name of dummy variables -# (i.e. not used). -dummy-variables-rgx=_|dummy - -# List of additional names supposed to be defined in builtins. Remember that -# you should avoid to define new builtins when possible. -additional-builtins= - -[CLASSES] - -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__,__new__,setUp - - -[DESIGN] - -# Maximum number of arguments for function / method -max-args=8 - -# Argument names that match this expression will be ignored. Default to name -# with leading underscore -ignored-argument-names=_.* - -# Maximum number of locals for function / method body -max-locals=20 - -# Maximum number of return / yield for function / method body -max-returns=8 - -# Maximum number of branch for function / method body -max-branchs=15 - -# Maximum number of statements in function / method body -max-statements=50 - -# Maximum number of parents for a class (see R0901). -max-parents=7 - -# Maximum number of attributes for a class (see R0902). -max-attributes=10 - -# Minimum number of public methods for a class (see R0903). -min-public-methods=1 - -# Maximum number of public methods for a class (see R0904). -max-public-methods=20 - -# Maximum number of nested blocks -max-nested-blocks=10 -[IMPORTS] - -# Deprecated modules which should not be used, separated by a comma -deprecated-modules=regsub,string,TERMIOS,Bastion,rexec - -# Create a graph of every (i.e. internal and external) dependencies in the -# given file (report RP0402 must not be disabled) -import-graph= - -# Create a graph of external dependencies in the given file (report RP0402 must -# not be disabled) -ext-import-graph= - -# Create a graph of internal dependencies in the given file (report RP0402 must -# not be disabled) -int-import-graph= diff --git a/README.rst b/README.rst index f871e24f2..8b70059cd 100644 --- a/README.rst +++ b/README.rst @@ -8,8 +8,8 @@ Web app extension for the `DIRAC project `_. Status master branch (stable): -.. image:: https://github.com/DIRACGrid/WebAppDIRAC/workflows/Basic%20tests/badge.svg?branch=rel-v4r3 - :target: https://github.com/DIRACGrid/WebAppDIRAC/actions?query=workflow%3A%22Basic+tests%22+branch%3Arel-v4r3 +.. image:: https://github.com/DIRACGrid/WebAppDIRAC/workflows/Basic%20tests/badge.svg?branch=rel-v5r0 + :target: https://github.com/DIRACGrid/WebAppDIRAC/actions?query=workflow%3A%22Basic+tests%22+branch%3Arel-v5r0 :alt: Basic Tests Status Status integration branch (devel): diff --git a/pyproject.toml b/pyproject.toml index dffffa9b6..416083fb4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,3 +11,62 @@ git_describe_command = "git describe --dirty --tags --long --match *[0-9]* --exc [tool.black] line-length = 120 target-version = ['py39'] + +[tool.pylint.basic] + +# We mostly have CamelCase, with a few differences. +# In tests we have quite some snake_case, mostly due to pytest +# We can instruct pylint to understand both, but the problem is that it +# will stick to one style per file (i.e if the first variable is snake, +# all the following must be snake) +# It's not quite the case yet... +# For the time being, I wrote the regex that matches best our code. +# (except for the services with their export_ and types_ ...) +# We will see about tests later... +# See https://pylint.readthedocs.io/en/latest/user_guide/messages/convention/invalid-name.html#multiple-naming-styles-for-custom-regular-expressions + +# Camel case with capital letter first +class-rgx = '([A-Z][a-z]*)+$' +module-rgx = '([A-Z][a-z]*)+$' + +# Attributes, variables, functions and methods +# are camelCase, but can start with one or two understcore +attr-rgx = '(?:_*[a-z]+([A-Z][a-z]*)*)$' +variable-rgx = '(?:_*[a-z]+([A-Z][a-z]*)*)$' +function-rgx = '(?:_*[a-z]+([A-Z][a-z]*)*)$' +method-rgx = '(?:_*[a-z]+([A-Z][a-z]*)*)$' + +argument-naming-style = "camelCase" + +[tool.pylint.main] +# Files or directories to be skipped. They should be base names, not paths. +ignore = [".svn", ".git"] + +# 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 = ["MySQLdb", "numpy"] + +# 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 = 0 + +[tool.pylint.typecheck] +# List of decorators that change the signature of a decorated function. +signature-mutators = [] + +[tool.pylint.format] + +# Maximum number of characters on a single line. +max-line-length = 130 + +[tool.pylint."messages control"] +disable = ["R0903","I0011","c-extension-no-member"] + +[tool.pylint.reports] +# 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 = "colorized" diff --git a/src/WebAppDIRAC/WebApp/handler/UPHandler.py b/src/WebAppDIRAC/WebApp/handler/UPHandler.py index d9a7bed3e..d6d58fc75 100644 --- a/src/WebAppDIRAC/WebApp/handler/UPHandler.py +++ b/src/WebAppDIRAC/WebApp/handler/UPHandler.py @@ -1,12 +1,12 @@ import base64 -import zlib import json +import zlib from DIRAC import S_OK -from DIRAC.Core.Utilities import DEncode from DIRAC.Core.DISET.ThreadConfig import ThreadConfig +from DIRAC.Core.Tornado.Server.private.BaseRequestHandler import authorization +from DIRAC.Core.Utilities import DEncode from DIRAC.FrameworkSystem.Client.UserProfileClient import UserProfileClient -from DIRAC.Core.Tornado.Server.TornadoREST import authorization from WebAppDIRAC.Lib.WebHandler import WebHandler, WErr