Skip to content

Conversation

@drvinceknight
Copy link
Member

This fixes the two errors:

axelrod/fingerprint.py:444: error: Function "numpy.array" is not valid as a type
22
axelrod/fingerprint.py:444: note: Perhaps you need "Callable[...]" or a callback protocol?
23
Found 1 error in 1 file (checked 1 source file)

and:

axelrod/strategies/ann.py:125: error: Incompatible types in assignment (expression has type "ndarray", variable has type "List[int]")
34
Found 1 error in 1 file (checked 1 source file)

note that in fingerprint.py I'm using the ArrayType type but that
when I tried to use that in ann.py a lot of other things broke.

This fixes the two errors:

```
axelrod/fingerprint.py:444: error: Function "numpy.array" is not valid as a type
22
axelrod/fingerprint.py:444: note: Perhaps you need "Callable[...]" or a callback protocol?
23
Found 1 error in 1 file (checked 1 source file)
```

and:

```
axelrod/strategies/ann.py:125: error: Incompatible types in assignment (expression has type "ndarray", variable has type "List[int]")
34
Found 1 error in 1 file (checked 1 source file)
```

note that in `fingerprint.py` I'm using the `ArrayType` type but that
when I tried to use that in `ann.py` a lot of other things broke.
@drvinceknight
Copy link
Member Author

This is failing due to numpy 1.20.0 not being yet what we run on the CI so numpy.typing is not available:

ImportError: Failed to import test module: axelrod
16
Traceback (most recent call last):
17
  File "/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/unittest/loader.py", line 462, in _find_test_path
18
    package = self._get_module_from_name(name)
19
  File "/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/unittest/loader.py", line 369, in _get_module_from_name
20
    __import__(name)
21
  File "/home/runner/work/Axelrod/Axelrod/axelrod/__init__.py", line 33, in <module>
22
    from axelrod.fingerprint import AshlockFingerprint, TransitiveFingerprint
23
  File "/home/runner/work/Axelrod/Axelrod/axelrod/fingerprint.py", line 18, in <module>
24
    from numpy.typing import ArrayLike
25
ModuleNotFoundError: No module named 'numpy.typing'

The version that gets install (numpy only has a lower bound pin in requirements.txt) is apparently numpy-1.19.5:

Collecting typing-extensions>=3.6.4
57
  Downloading typing_extensions-3.7.4.3-py3-none-any.whl (22 kB)
58
Installing collected packages: zipp, typing-extensions, six, wcwidth, sortedcontainers, pyyaml, pytz, python-dateutil, pyparsing, pillow, numpy, kiwisolver, importlib-metadata, cycler, attrs, tqdm, toolz, scipy, prompt-toolkit, pandas, matplotlib, hypothesis, fsspec, dask, cloudpickle
59
Successfully installed attrs-20.3.0 cloudpickle-1.6.0 cycler-0.10.0 dask-2021.3.0 fsspec-0.8.7 hypothesis-5.19.3 importlib-metadata-3.9.1 kiwisolver-1.3.1 matplotlib-3.3.4 numpy-1.19.5 pandas-1.1.5 pillow-8.1.2 prompt-toolkit-3.0.18 pyparsing-2.4.7 python-dateutil-2.8.1 pytz-2021.1 pyyaml-5.4.1 scipy-1.5.4 six-1.15.0 sortedcontainers-2.3.0 toolz-0.11.1 tqdm-4.59.0 typing-extensions-3.7.4.3 wcwidth-0.2.5 zipp-3.4.1

Note we can also remove it from the docs.
@marcharper marcharper merged commit 532c6f6 into marcharper-patch-1 Mar 29, 2021
@marcharper marcharper deleted the marcharper-patch-1-fix-type-hints branch July 3, 2022 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants