diff --git a/CHANGES.rst b/CHANGES.rst index bf38d5b65..e62b533e3 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -25,6 +25,7 @@ Internal changes * In order to ensure documentation can be rebuilt at a later time, errors raised by `sphinx` linkcheck are now set to be ignored when building the documentation. (:pull:`1375`). * With the publication of `xclim`, the code repository now offers a `CITATION.cff` configuration for users to properly cite the software (APA formatted and raw BibTeX) for academic purposes. (:issue:`95`, :pull:`250`). * Logging messages emitted when redefining units via `pint` (caused by `logging` interactions with dependencies) have been silenced. (:issue:`1373`, :pull:`1384`). +* Fixed some annotations and dev dependencies issues to allow the development of xclim inside a python 3.11 environment. (:issue:`1376`, :pull:`1381`). v0.43.0 (2023-05-09) -------------------- diff --git a/environment.yml b/environment.yml index 6273399af..53ff4139b 100644 --- a/environment.yml +++ b/environment.yml @@ -15,18 +15,17 @@ dependencies: - lmoments3 - numba - numpy>=1.16 - - pandas>=0.23,<2.0 # Pinned due to incompatibility with xarray <=2023.03 + - pandas>=0.23 - pint>=0.9 - poppler>=0.67 - pyyaml - scikit-learn>=0.21.3 - scipy>=1.2 + - statsmodels - xarray>=2022.06.0 # Extras - - clisops - eofs - flox - - pytest-json-report # Added due to a packaging bug with ESMPy. See: https://github.com/esmf-org/esmf/issues/115 # Testing and development dependencies - black>=22.12 - blackdoc @@ -34,6 +33,7 @@ dependencies: - cairosvg - coverage - distributed>=2.0 + - filelock - flake8 - flake8-rst-docstrings - flit @@ -50,7 +50,7 @@ dependencies: - pre-commit - pybtex - pydocstyle - - pylint<2.15 + - pylint - pytest - pytest-cov - pytest-xdist>=3.2 @@ -58,9 +58,8 @@ dependencies: - sphinx-autodoc-typehints - sphinx-codeautolink - sphinx-copybutton - - sphinx-rtd-theme>=1.0 + - sphinx_rtd_theme>=1.0 - sphinxcontrib-bibtex - - statsmodels - tokenize-rt - tox # - tox-conda # Will be added when a tox@v4.0+ compatible plugin is released. diff --git a/pylintrc b/pylintrc index f8faf05a3..cdac8c797 100644 --- a/pylintrc +++ b/pylintrc @@ -195,8 +195,8 @@ timeout-methods=requests.api.delete,requests.api.get,requests.api.head,requests. [EXCEPTIONS] # Exceptions that will emit a warning when caught. -overgeneral-exceptions=BaseException, - Exception +overgeneral-exceptions=builtins.BaseException, + builtins.Exception [REFACTORING] diff --git a/pyproject.toml b/pyproject.toml index 24a526087..a41b2818d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,7 +69,7 @@ dev = [ "pre-commit >=2.9", "pydocstyle >=5.1.1", "pybtex", - "pylint <2.15", + "pylint", "pytest", "pytest-cov", "pytest-xdist[psutil] >=3.2", diff --git a/xclim/core/indicator.py b/xclim/core/indicator.py index 56d57adc4..5234bae67 100644 --- a/xclim/core/indicator.py +++ b/xclim/core/indicator.py @@ -190,11 +190,11 @@ class Parameter: _empty = _empty kind: InputKind - default: "Any" = _empty_default + default: Any = _empty_default description: str = "" units: str = _empty choices: set = _empty - value: "Any" = _empty + value: Any = _empty def update(self, other: dict) -> None: """Update a parameter's values from a dict.""" @@ -302,30 +302,30 @@ class Indicator(IndicatorRegistrar): Parameters ---------- identifier : str - Unique ID for class registry, should be a valid slug. + Unique ID for class registry, should be a valid slug. realm : {'atmos', 'seaIce', 'land', 'ocean'} - General domain of validity of the indicator. Indicators created outside xclim.indicators must set this attribute. + General domain of validity of the indicator. Indicators created outside xclim.indicators must set this attribute. compute : func - The function computing the indicators. It should return one or more DataArray. + The function computing the indicators. It should return one or more DataArray. cf_attrs : list of dicts - Attributes to be formatted and added to the computation's output. - See :py:attr:`xclim.core.indicator.Indicator.cf_attrs`. + Attributes to be formatted and added to the computation's output. + See :py:attr:`xclim.core.indicator.Indicator.cf_attrs`. title : str - A succinct description of what is in the computed outputs. Parsed from `compute` docstring if None (first paragraph). + A succinct description of what is in the computed outputs. Parsed from `compute` docstring if None (first paragraph). abstract : str - A long description of what is in the computed outputs. Parsed from `compute` docstring if None (second paragraph). + A long description of what is in the computed outputs. Parsed from `compute` docstring if None (second paragraph). keywords : str - Comma separated list of keywords. Parsed from `compute` docstring if None (from a "Keywords" section). + Comma separated list of keywords. Parsed from `compute` docstring if None (from a "Keywords" section). references : str - Published or web-based references that describe the data or methods used to produce it. Parsed from - `compute` docstring if None (from the "References" section). + Published or web-based references that describe the data or methods used to produce it. Parsed from + `compute` docstring if None (from the "References" section). notes : str - Notes regarding computing function, for example the mathematical formulation. Parsed from `compute` - docstring if None (form the "Notes" section). + Notes regarding computing function, for example the mathematical formulation. Parsed from `compute` + docstring if None (form the "Notes" section). src_freq : str, sequence of strings, optional - The expected frequency of the input data. Can be a list for multiple frequencies, or None if irrelevant. + The expected frequency of the input data. Can be a list for multiple frequencies, or None if irrelevant. context : str - The `pint` unit context, for example use 'hydro' to allow conversion from kg m-2 s-1 to mm/day. + The `pint` unit context, for example use 'hydro' to allow conversion from kg m-2 s-1 to mm/day. Notes ----- @@ -368,7 +368,7 @@ class Indicator(IndicatorRegistrar): # Note: typing and class types in this call signature will cause errors with sphinx-autodoc-typehints # See: https://github.com/tox-dev/sphinx-autodoc-typehints/issues/186#issuecomment-1450739378 - _all_parameters: dict[str, "Parameter"] = {} + _all_parameters: dict = {} """A dictionary mapping metadata about the input parameters to the indicator. Keys are the arguments of the "compute" function. All parameters are listed, even @@ -378,7 +378,7 @@ class Indicator(IndicatorRegistrar): # Note: typing and class types in this call signature will cause errors with sphinx-autodoc-typehints # See: https://github.com/tox-dev/sphinx-autodoc-typehints/issues/186#issuecomment-1450739378 - cf_attrs: list[dict[str, "Any"]] = None + cf_attrs: list[dict[str, str]] = None """A list of metadata information for each output of the indicator. It minimally contains a "var_name" entry, and may contain : "standard_name", "long_name", diff --git a/xclim/core/utils.py b/xclim/core/utils.py index 069c52d09..9c286cc33 100644 --- a/xclim/core/utils.py +++ b/xclim/core/utils.py @@ -582,9 +582,16 @@ class InputKind(IntEnum): """ -def infer_kind_from_parameter(param: Parameter, has_units: bool = False) -> InputKind: +def infer_kind_from_parameter(param, has_units: bool = False) -> InputKind: """Return the appropriate InputKind constant from an ``inspect.Parameter`` object. + Parameters + ---------- + param : Parameter + has_units : bool + + Notes + ----- The correspondence between parameters and kinds is documented in :py:class:`xclim.core.utils.InputKind`. The only information not inferable through the `inspect` object is whether the parameter has been assigned units through the :py:func:`xclim.core.units.declare_units` decorator.