Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision b4df039c6fe478297e532720e76d1213022410d5 authored by Jesper Nielsen on 26 October 2022, 08:27:38 UTC, committed by GitHub on 26 October 2022, 08:27:38 UTC
Fix mypy error. (#2009)
1 parent dc84ca2
  • Files
  • Changes
  • 03384ba
  • /
  • gpflow
  • /
  • type_flags.py
Raw File Download
Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
revision badge
swh:1:rev:b4df039c6fe478297e532720e76d1213022410d5
directory badge Iframe embedding
swh:1:dir:1bb343ff1415aab0fb8d8187aeb976ea73886095
content badge Iframe embedding
swh:1:cnt:eabf076e1cb1f4e05530e2a4ad3cd946008cc6a5
Citations

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
type_flags.py
# Copyright 2022 The GPflow Contributors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Code for setting type hints, depending on library versions.
"""
import sys

from numpy import __version__ as np_version
from packaging.version import Version

NP_VERSION = Version(np_version)

NP_TYPE_CHECKING = False
"""
Whether to type-check numpy arrays at all. Defaults to False, because we don't know which
versions a client might use.
"""

GENERIC_NP_ARRAYS = (sys.version_info >= (3, 9)) and (NP_VERSION >= Version("1.22.0"))
"""
Whether to use generic numpy arrays. This is not applied at all, if type checking and not
`NP_TYPE_CHECKING`.
"""


def compute_mypy_flags() -> str:  # pragma: no cover
    from mypy.version import __version__ as mypy_version

    MYPY_VERSION = Version(mypy_version)

    flags = []

    def set_always(variable: str, value: bool) -> None:
        if value:
            flags.append("--always-true")
        else:
            flags.append("--always-false")
        flags.append(variable)

    set_always("NP_TYPE_CHECKING", True)
    set_always("GENERIC_NP_ARRAYS", NP_VERSION >= Version("1.21.0"))
    if MYPY_VERSION >= Version("0.940"):
        flags.extend(["--enable-error-code", "ignore-without-code"])

    return " ".join(flags)
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Contact— JavaScript license information— Web API

back to top