mypy throws "error: Too many arguments for 'object'" on pre-commit hook run but not on local run - mypy

from typing import Callable, Type, TypeVar
T = TypeVar("T")
def repo(class_: Type[T]) -> Callable:
def instantiate(*args, **kwargs) -> T:
return class_(*args, **kwargs)
return instantiate
Code above throws "error: Too many arguments for 'object'" on pre-commit hook run but not on local run (python poetry run mypy repo.py).
Neither error message nor difference of behaviour between hook and local run make sense to me.
Any clue?
Thanks.

you've got a version mismatch between your two environments.
the one that is failing is mypy<=0.910:
$ mypy --version
mypy 0.910
$ mypy t.py
t.py:7: error: Too many arguments for "object"
Found 1 error in 1 file (checked 1 source file)
the one that's passing is mypy>0.910
$ mypy --version
mypy 0.971 (compiled: yes)
$ mypy t.py
Success: no issues found in 1 source file

Related

Mypy does not ignore mpi4py module with syntax error

In mypy.ini there is
[mypy-mpi4py]
ignore_missing_imports = True
With this mypy is getting the following error
Success: no issues found in 4 source files
s\d\L\.env\lib\site-packages\mpi4py\MPI.pyi:948: error:
invalid syntax [syntax]
def __new__(cls, buf: Buffer, /) -> memory: ...
^
Found 1 error in 1 file (errors prevented further checking)
Success: no issues found in 3 source files
How can I setup the config to ignore the module ?

Uncaught ReferenceError: BroadcastChannel is not defined

Trying to run deno locally for a deno deploy app which supports broadcast channel but getting this compilation error how do I fix it?
const channel = new BroadcastChannel('')
Uncaught ReferenceError: BroadcastChannel is not defined
It's in the stable docs for v1.17.1, so shouldn't need --unstable to use it:
https://doc.deno.land/deno/stable#v1.17.1/~/BroadcastChannel
Compare with unstable: https://doc.deno.land/deno/unstable#v1.17.1
However, in reality that's not the case:
$ deno
Deno 1.17.1
exit using ctrl+d or close()
> new BroadcastChannel()
Uncaught ReferenceError: BroadcastChannel is not defined
at <anonymous>:2:1
> close()
$ deno --unstable
Deno 1.17.1
exit using ctrl+d or close()
> new BroadcastChannel()
Uncaught TypeError: Failed to construct 'BroadcastChannel': 1 argument required, but only 0 present.
at Object.requiredArguments (deno:ext/webidl/00_webidl.js:627:13)
at new BroadcastChannel (deno:ext/broadcast_channel/01_broadcast_channel.js:81:14)
at <anonymous>:2:1
> close()
You can file an issue in the repo.
Edit: Issue created: denoland/deno#13214

pyOptSparse Error: There was an error importing the compiled snopt module during testing of OpenMDAO

I need to use open framework openMDAO for my project in Ubuntu. I have successfully installed mpi4py, petsc, petsc4py by creating new environment in anaconda. I have also installed pyoptsparse and other libraries.
After installation when I run test command $ testflo openmdao -n 1
It gives error as:
(omd) mujahed#Lenovo-G50-80:~$ testflo openmdao -n 1
.............................................................................
+------------------------------------------------------------------------------+
| pyOptSparse Error: There was an error importing the compiled snopt module |
+------------------------------------------------------------------------------+
SSS......../home/mujahed/anaconda3/envs/omd/lib/python3.8/site-packages/openmdao/core/group.py:1113: UserWarning:Group (sub): Attempted to connect from &apos;tgt.x&apos; to &apos;cmp.x&apos;, but &apos;tgt.x&apos; is an input. All connections must be from an output to an input.
.......................................................................................................................................................................................................................................................................................................................................................S...............................................................................................................................S........................................................................S.SS........................................................................................................................................................................................................................................................................SSS.SSSSSS..S.................................................................................................................................................................................................................................................................................................................S.......
+------------------------------------------------------------------------------+
| pyOptSparse Error: There was an error importing the compiled snopt module |
+------------------------------------------------------------------------------+
.....................................................................(mpi) /home/mujahed/anaconda3/envs/omd/lib/python3.8/site-packages/openmdao/core/tests/test_prob_remote2.py:ProbRemoteTestCase.test_get_remote ... FAIL (00:00:0.02, 203 MB)
Traceback (most recent call last):
File "/home/mujahed/anaconda3/envs/omd/lib/python3.8/site-packages/testflo/test.py", line 425, in _try_call
func()
File "/home/mujahed/anaconda3/envs/omd/lib/python3.8/site-packages/openmdao/core/tests/test_prob_remote2.py", line 200, in test_get_remote
prob.get_val(&apos;par.c2.x&apos;, get_remote=False)
File "/home/mujahed/anaconda3/envs/omd/lib/python3.8/unittest/case.py", line 227, in __exit__
self._raiseFailure("{} not raised".format(exc_name))
File "/home/mujahed/anaconda3/envs/omd/lib/python3.8/unittest/case.py", line 164, in _raiseFailure
raise self.test_case.failureException(msg)
AssertionError: RuntimeError not raised
...
+------------------------------------------------------------------------------+
| pyOptSparse Error: There was an error importing the compiled snopt module |
+------------------------------------------------------------------------------+
SSS...............................................S.....X......................................................................................................................................................................................
+------------------------------------------------------------------------------+
| pyOptSparse Error: There was an error importing the compiled snopt module |
+------------------------------------------------------------------------------+
..SS............S...capi_return is NULL
Call-back cb_slfunc_in_slsqp__user__routines failed.
.capi_return is NULL
Call-back cb_slfunc_in_slsqp__user__routines failed.
....S..........................SSSSSSS.......
Normal return from subroutine COBYLA
NFVALS = 56 F =-1.080000E+02 MAXCV = 0.000000E+00
X = 3.500001E+00 -3.500001E+00
.................................................
Normal return from subroutine COBYLA
NFVALS = 124 F =-2.733333E+01 MAXCV = 0.000000E+00
X = 6.666667E+00 -7.333332E+00
.....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................SSSSSSSSSSSSSSSSSSSSSSSS..............
Normal return from subroutine COBYLA
NFVALS = 54 F =-2.700000E+01 MAXCV = 0.000000E+00
X = 6.999999E+00 -6.999999E+00
.............................................SSS..............................................................................................................S...........................................................................................................................................................................................................................................................................................................................................................
The following tests failed:
test_prob_remote2.py:ProbRemoteTestCase.test_get_remote
Passed: 2619
Failed: 1
Skipped: 62
Ran 2682 tests using 1 processes
Wall clock time: 00:22:33.07
Passed: 2619
Failed: 1
Skipped: 62
I don’t have computer science background and this is the first time I am dealing with something like this.
I am using:
openMDAO 3.2.1
mpich 3.3.2
mpi4py 3.0.3
petsc 3.13.4
petsc4py 3.13.0
pyoptsparse 2.1.5
python 3.8.5
I have build pyoptsparse from https://github.com/OpenMDAO/build_pyoptsparse by command ./build_pyoptsparse.sh.
I have Ubuntu 20.04.1 LTS and I am using Anaconda3. How can I pass all the tests (Without skipping)?
Can please anyone help me with this?
Apologies for this.. it looks like an extraneous file (test_prob_remote2.py) made it into the distribution.. This is not a legitimate test and you can ignore it.
The "pyOptSparse Error" messages are just telling you that you don't have the SNOPT optimizer installed, which is fine.
Your installation should be good.
Some of that test output can be a bit confusing. The error you're getting isn't actually with SNOPT. Thats a warning spit out by pyoptsparse, but it is not a problem.
The actual failed test is identified by this line:
The following tests failed:
test_prob_remote2.py:ProbRemoteTestCase.test_get_remote
And the error that causes the failure is here:
File "/home/mujahed/anaconda3/envs/omd/lib/python3.8/site-packages/testflo/test.py", line 425, in _try_call
func()
File "/home/mujahed/anaconda3/envs/omd/lib/python3.8/site-packages/openmdao/core/tests/test_prob_remote2.py", line 200, in test_get_remote
prob.get_val('par.c2.x', get_remote=False)
File "/home/mujahed/anaconda3/envs/omd/lib/python3.8/unittest/case.py", line 227, in __exit__
self._raiseFailure("{} not raised".format(exc_name))
File "/home/mujahed/anaconda3/envs/omd/lib/python3.8/unittest/case.py", line 164, in _raiseFailure
raise self.test_case.failureException(msg)
AssertionError: RuntimeError not raised
For some reason your install isn't raising an error when one is expected. Im not sure why thats going on, but if you're not planning to run with MPI then its not a problem.
You have bothered to install MPI, so you are probably be planning to run things in parallel... this one failed test is certainly odd. If you had a serious problem with your MPI install you would get more failed tests I think.
You could try running testflo like this:
testflo openmdao -n 1 --show_skipped to see if more MPI tests are being skipped... that might help you narrow it down.

Grunt plugin grunt-exec v2.0.0 doesn't execute a simple command while v1.0.1 does

I was using grunt-exec v1.0.1 with this configuration in Gruntfile.js:
grunt.initConfig({
exec: {
tsc: {
cmd: "tsc"
}
},
...
}
...
grunt.loadNpmTasks('grunt-exec');
grunt.registerTask('debug', [
...
'exec:tsc',
...
]);
Then running grunt debug in console tsc is executed correctly.
In another project with similar configuration it's installed the last version of
grunt-exec(v.2.0.0) and running grunt-debug the next error is returned:
Running "exec:tsc" (exec) task
>> Failed with: Error: spawn tsc ENOENT
Warning: Task "exec:tsc" failed. Use --force to continue.
With -verbose option it returns:
Running "exec:tsc" (exec) task
Verifying property exec.tsc exists in config...OK
File: [no files]
tsc
buffer : disabled
timeout : infinite
killSig : SIGTERM
shell : true
command : tsc
args : []
stdio : [ignore,pipe,pipe]
cwd : D:\Pruebas\Angular 2\ATemplate
exitcodes: 0
pid : undefined
>> Failed with: Error: spawn tsc ENOENT
Warning: Task "exec:tsc" failed. Use --force to continue.
I know I can have it working using v1.0.1 of grunt-exec but I want to know how must I do it with v2.0.0. The project documentation in github has not given me a clue.
Looks like the grunt-exec version v2.0.0 uses some ECMAScript features that are not supported in older versions of node.
The first one i saw was:
Symbol.match, String.prototype.endsWith that is not supported in node < v6.10.2
See here: http://node.green/
Upgrade your node version to fix this issue.

Why3 is unable to run prover on windows via cygwin

I am trying to use cvc4 prover with Frama-c wp plugin through Why3 on Windows environment. I have frama-c and why3 installed on my system. Why3 is configured properly to include cvc4 as a prover :
$ why3 --list-provers
Known provers:
Alt-Ergo (0.95.2)
CVC4 (1.4)
I used frama-c Wp plugin to generate why3 format (.why) file corresponding to my .c file (C source file with ACSL Specifications) with following command:
frama-c -wp -wp-print -wp-proof-trace -wp-out C:/Users/user/temp -wp-prover cvc4 swap.c
The above command generate a file swap_Why3_ide.why in C:/Users/user/temp/typed directory.
When I try to prove Theories in generated swap_Why3_ide.why file using why3 with cvc4 as prover it fails with following error:
$ why3 prove -P cvc4 -L C:/cygwin/usr/local/share/frama-c/wp/why3 temp/typed/swap_Why3_ide.why
temp/typed/swap_Why3_ide.why VCswap_post WP : HighFailure (0.02s)
Prover exit status: exited with status 1
Prover output:
/usr/local/lib/why3/why3-cpulimit: Error: failed when launching <"/cygdrive/c/cvc4-1.4-win32-opt.exe" "--lang=smt2" "/tmp/why_29ba75_swap_Why3_ide-T-WP.smt2">
Fatal: CreateProcess failed with error 0: The operation completed successfully.
I performed same steps on a linux environment and why3 was able to execute prover:
why3 prove -P cvc4 -L /usr/local/share/frama-c/wp/why3/ temp/typed/swap_Why3_ide.why
temp/typed/swap_Why3_ide.why VCswap_post WP : Valid (0.05s)
Can anyone suggest how to execute Why3 on windows?
It seems like no one is using why3 on Windows. But anyways, for anyone who will try to use Why3 on windows in future, here are steps I performed to run a prover on theories in a .why file:
1) On Windows, even if provers are installed, executing why3 config --detect will not add provers. So when executing why3 config --detect --add-prover cvc4 path_to_executable_in_Windows_format make sure that path to executable is in windows format( for example C:\provers\cvc4-1.4-win32-opt.exe)
If path is not in windows format, following error is thrown:
/usr/local/lib/why3/why3-cpulimit: Error: failed when launching <"/cygdrive/c/cvc4-1.4-win32-opt.exe" "--lang=smt2" "/tmp/why_29ba75_swap_Why3_ide-T-WP.smt2">
Fatal: CreateProcess failed with error 0: The operation completed successfully.
2) After setting path to provers properly, try to execute why3 as follows:
why3 prove -P cvc4 -L C:/cygwin/usr/local/share/frama-c/wp/why3 C:/temp/typed/swap_Why3_ide.why
This will throw following error:
C:/temp/typed/swap_Why3_ide.why VCswap_post WP : HighFailure (0.03s)
Prover exit status: exited with status 1
Prover output:
(error "Couldn't open file: /tmp/why_727ef8_swap_Why3_ide-T-WP.smt2")
why3cpulimit cpu time: 0.015625s wall time: 0.015625s
This error is occurring because why3 generates *.smt2 files in cygwin tmp directory (/tmp) and when provers are called over these files complete path to these files in not provided and prover complain that it Couldn't open file /tmp/XX.smt2
To fix this I had to update command executed to run prover in .why3.conf as following:
[prover]
command = "%l/why3-cpulimit %t %m -s C:/provers/cvc4-1.4-win32-opt.exe --lang=smt2 C:/cygwin%f
driver = "/usr/local/share/why3/drivers/cvc4.drv"
editor = ""
in_place = false
interactive = false
name = "CVC4"
shortcut = "cvc4"
version = "1.4"
Note that I changed the file format from %f to C:/cygwin%f which is windows path to /tmp directory

Resources