python / typeshed

Collection of library stubs for Python, with static types
Other
4.3k stars 1.73k forks source link

pyright fails with "Unexpected token ;" #12514

Closed papadeltasierra closed 1 month ago

papadeltasierra commented 1 month ago

Trying to add some types to typeshed and running the tests locally on Ubuntu. pyright fails with the error above and below is the best stack I can create.

(.venv) pds@PDSDELL:~/git/typeshed$ npx pyright stubs/stone/stone/__init__.pyi
/home/pds/.cache/pyright-python/1.1.375/node_modules/pyright/dist/vendor.js:2
exports.id=968,exports.ids=[968],exports.modules={6596:(A,e,t)=>{"use strict";const r=t(1160),o=global.Date;class i extends o{constructor(A){super(A),this.isDate=!0}toISOString(){return`${this.getUTCFullYear()}-${r(2,this.getUTCMonth()+1)}-${r(2,this.getUTCDate())}`}}A.exports=A=>{const e=new i(A);if(isNaN(e))throw new TypeError("Invalid Datetime");return e}},4023:(A,e,t)=>{"use strict";const r=t(1160);class o extends Date{constructor(A){super(A+"Z"),this.isFloating=!0}toISOString(){return`${this.getUTCFullYear()}-${r(2,this.getUTCMonth()+1)}-${r(2,this.getUTCDate())}T${r(2,this.getUTCHours())}:${r(2,this.getUTCMinutes())}:${r(2,this.getUTCSeconds())}.${r(3,this.getUTCMilliseconds())}`}}A.exports=A=>{const e=new o(A);if(isNaN(e))throw new TypeError("Invalid Datetime");return e}},692:A=>{"use strict";A.exports=A=>{const e=new Date(A);if(isNaN(e))throw new TypeError("Invalid Datetime");return e}},7640:(A,e,t)=>{"use strict";const r=

SyntaxError: Unexpected token ;
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.o.f.require (/home/pds/.cache/pyright-python/1.1.375/node_modules/pyright/dist/pyright.js:1:2393)
    at Promise.all.Object.keys.reduce (/home/pds/.cache/pyright-python/1.1.375/node_modules/pyright/dist/pyright.js:1:1862)
    at Array.reduce (<anonymous>)

This happens regardless of the file being checked so looks like a pyright issue.

JelleZijlstra commented 1 month ago

This happens regardless of the file being checked so looks like a pyright issue.

It does indeed. Could you report this issue to pyright instead of typeshed?

JelleZijlstra commented 1 month ago

Most likely related to some issue with your local version of node or npm or some similar tool, though.

Akuli commented 1 month ago

You seem to be using pyright-python (your error message mentions it), so maybe report this to https://github.com/RobertCraigie/pyright-python.

papadeltasierra commented 1 month ago

Thanks @JelleZijlstra and @Akuli . I spent sometime updating Ubunto from 20.04 to 22.04 and ensuring that I had up to date node.js and between the two this seems to have solved the issue.