starteddtolnay/remain

started time in 9 hours

issue openeddtolnay/remain

Struct field support

Neat package! I saw Alex Crichton mention it in his RustLatam talk about procedural macros, right after looking at rust-lang/rustfmt#3422 and rust-lang/rust-clippy#3822 discussing options for making sure that struct fields are sorted. This had was wondering if you were considering adding support for also ensuring that struct fields remain sorted, or if you wanted to keep it only focused on enums.

Cheers

created time in 9 hours

issue commentrust-lang/rustfmt

Feature request: alphabetic sorting of struct/enum fields

In addition to being able to sort fields, it would also be nice to be able to sort top-level items (Structs, Traits, etc.) in a file.

PvdBerg1998

comment created time in 10 hours

issue commentjeremyBanks/hide-hnq

Not working as of April 2019

(Previously replied by email, but for public reference:) I am no longer maintaining this extension, and I no longer use Chrome. I will archive this repo for clarity, but if someone wants to fork and fix, I would be happy to add a notice directing visitors there instead.

darthwalsh

comment created time in a day

push eventjeremyBanks/hide-hnq

Jeremy Banks

commit sha 3a437df008f4fc2be7b6a36e4ae452b1b2068b6d

release under MIT and Blue Oak licenses

view details

push time in 2 days

PublicEvent
GollumEvent

startedcitybound/citybound

started time in 17 days

starteddanistefanovic/build-your-own-x

started time in 22 days

issue closedMicrosoft/pyright

`if isinstance(instance, SuperClass):` loses type

Sort-of the reverse of #24: InstanceOfTypeConstraint constrains the subject's type to None/Never when it's checked against a superclass.

Maybe this should be a no-op instead? I'm not entirely sure, but mypy doesn't flag this as an error.

class SuperClass:
    def __init__(self) -> None:
        self.property: None = None

class MyClass(SuperClass):
    pass

def f(instance: MyClass) -> None:
    if isinstance(instance, SuperClass):
        print(instance.property)
$ npx pyright@1.0.4 server/src/tests/samples/isinstance.py
Finding source files
Found 1 source files
Analyzed 1 file in 0.981sec
/mnt/c/Users/_/pyright/server/src/tests/samples/isinstance.py
  'property' is not a known member of 'None' (10, 24)
1 error, 0 warnings

Equivalent example with object instead of an explicit superclass:

class MyClass:
    def __init__(self) -> None:
        self.property: None = None

def f(instance: MyClass) -> None:
    if isinstance(instance, object):
        print(instance.property)

closed time in a month

jeremyBanks

issue commentMicrosoft/pyright

`if isinstance(instance, SuperClass):` loses type

LGTM, thanks! I tried a few similar examples and pyright@master's results were consistent with MyPy.

jeremyBanks

comment created time in a month

delete tag jeremyBanks/pyright

delete tag : 2019.03.23

delete time in a month

delete tag jeremyBanks/pyright

delete tag : 1.0.0

delete time in a month

delete branch jeremyBanks/pyright

delete branch : master

delete time in a month

create barnchjeremyBanks/pyright

branch : dev

created branch time in a month

delete branch jeremyBanks/pyright

delete branch : issue-24

delete time in a month

push eventjeremyBanks/pyright

Jeremy Banks

commit sha e618866e23a9446cbe3d36c715aca139e14b4d89

WIP

view details

push time in a month

issue openedMicrosoft/pyright

`if isinstance(instance, SuperClass):` loses type instead of being no-op

Sort-of the reverse of #24: InstanceOfTypeConstraint constrains the subject's type to None/Never when it's checked against a superclass. This should probably be a no-op instead.

class SuperClass:
    def __init__(self) -> None:
        self.property: None = None

class MyClass(SuperClass):
    pass

def f(instance: MyClass) -> None:
    if isinstance(instance, SuperClass):
        print(instance.property)
$ npx pyright@1.0.4 server/src/tests/samples/isinstance.py
Finding source files
Found 1 source files
Analyzed 1 file in 0.981sec
/mnt/c/Users/_/pyright/server/src/tests/samples/isinstance.py
  'property' is not a known member of 'None' (10, 24)
1 error, 0 warnings

Equivalent example with object instead of an explicit superclass:

class MyClass:
    def __init__(self) -> None:
        self.property: None = None

def f(instance: MyClass) -> None:
    if isinstance(instance, object):
        print(instance.property)

created time in a month

issue commentMicrosoft/pyright

Document how to run Pyright from a git branch

I'm not sure if this is the same confusion as the OP, but FWIW when I first downloaded and built pyright (from a release tag) I was confused because it didn't seem to be using the built-in typeshed definitions by default, so it was complaining that things like instanceof weren't defined. The actual installed release build seems to use these automatically, but I eventually realized I needed to specify -t dist/typeshed-fallback to get the same behaviour when I built myself. Perhaps that could be clarified (or fixed, if that isn't supposed to be necessary).

gwk

comment created time in a month

push eventjeremyBanks/pyright

Jeremy Banks

commit sha fdbdb4dbead193ddafda0f11b3e0107ce24f1eaf

WIP

view details

push time in a month

push eventjeremyBanks/pyright

Jeremy Banks

commit sha efbac96c01ea1f2dc6695ed1960b31205bf28bd4

WIP

view details

push time in a month

create barnchjeremyBanks/pyright

branch : issue-24

created branch time in a month

push eventjeremyBanks/pyright

Bruno P. Kinoshita

commit sha df84fe04e375e02d9998137841c475d0f0ddfa56

Be consistent on log messages, using file location instead of URI as in other methods

view details

Eric Traut

commit sha 08baed6f0620e8457beddbcb91531385aac550b1

Merge pull request #5 from kinow/log-consistency-1 Be consistent on log messages, using file location instead of URI as in other methods

view details

Eric Traut

commit sha a2c1fdef39c88237db02274a1cf7abbd7c77d45b

Fixed bug that caused a crash when last file in program was removed from the source file list.

view details

Eric Traut

commit sha 8afce050bdba2305bc657b230fa73a609cb85626

Fixed unit tests.

view details

Eric Traut

commit sha 396b6888fb07ee1a812b57171ac19d4dc540dd20

Fixed crashing bug that could occur if typeshed files were not found.

view details

Eric Traut

commit sha 5e83a19a0460202a1cf6b32b3a870c55240c6006

Added "source" string to diagnostics output so errors and warnings are displayed with "pyright" in VS Code.

view details

Eric Traut

commit sha 0563813b9e9fff268e70e1a7b5a4a88ca177524c

Updated build scripts to build command-line version into an npm module.

view details

Eric Traut

commit sha c9b18356a4bd95c14a56932b80db80f538d9b520

Removed postinstall script so npm installation is possible.

view details

Eric Traut

commit sha e7e9e0a8ebc586f8f290e64e888ed99241ee9815

Added logic in command-line parser to print usage if no files or projects are specified. Added "bin" section to project.json. Bumped version to 1.0.3.

view details

Eric Traut

commit sha f5362e9e09c577f3e04dd05174a6283c25a0a4b4

Added installation instructions for command-line tool.

view details

Eric Traut

commit sha 026a1f48c082bbf772234876d2b578778ad66bff

Added more documentation around the -v command-line switch.

view details

Eric Traut

commit sha 7e859f73d9114f59852f4a8869754747a0001cda

Fixed a couple of bugs in the docs.

view details

push time in a month

issue openedMicrosoft/pyright

`isinstance(instance, SubClass)` loses type instead of narrowing

Given an instance of a SuperClass, I would expect isinstance(instance, SubClass) to narrow the type of instance to SubClass in the following branch. Instead, the type appears to have been lost and replaced with NoneType.

class SuperClass:
    def __init__(self) -> None:
        self.property: bool = True

class SubClass(SuperClass):
    pass

def function(instance: SuperClass) -> None:
    if isinstance(instance, SubClass):
        print(instance.property)
$ mypy --strict example.py && echo "no errors"
no errors
$ pyright example.py
Finding source files
Found 1 source files
Analyzed 1 file in 1.229sec
/Users/jbanks/Desktop/example.py
  'property' is not a known member of 'None' (10, 24)
1 error, 0 warnings

For a slightly smaller example, we get the same error narrowing from the base object type:

class MyClass:
    def __init__(self) -> None:
        self.property: bool = True


def function(instance: object) -> None:
    if isinstance(instance, MyClass):
        print(instance.property)

created time in a month

issue commentMicrosoft/pyright

Unable to initialize a constrained defaultdict

That this may be a duplicate of #19, or it may requires further changes.

jeremyBanks

comment created time in a month

issue openedMicrosoft/pyright

Unable to initialize a constrained defaultdict

My code has a collections.defaultdict mapping from strs to ints, default to 0 for missing values. I've been using the following annotations with MyPy to enforce those types.

from collections import defaultdict
from typing import DefaultDict

x: DefaultDict[str, int] = defaultdict(int)

However, Pyright tells me that the assignment is illegal.

Expression of type 'defaultdict[Any, Any]' cannot be assigned to type 'DefaultDict[str, int]'

created time in a month

fork jeremyBanks/pyright

Static type checker for Python

fork in a month

startedMicrosoft/pyright

started time in a month

PR opened tms/stack-utilities

we https now

https://meta.stackexchange.com/q/292058/134300

+2 -2

0 comment

1 changed file

pr created time in a month

push eventjeremyBanks/stack-utilities

Jeremy Banks

commit sha 0bb3d18a289a3cac4a553dc4b3d25daf70ee6a61

we https now https://meta.stackexchange.com/q/292058/134300

view details

push time in a month

fork jeremyBanks/stack-utilities

Small utilities that aren't worth cluttering up StackExchangeScripts with

fork in a month

fork jeremyBanks/ffsend

:mailbox_with_mail: Easily and securely share files from the command line. A fully featured Firefox Send client.

https://gitlab.com/timvisee/ffsend

fork in a month

create barnchjeremyBanks/deno

branch : hello-world

created branch time in 3 months

issue commentwhatwg/html

Synchronous clone = global.structuredClone(value, transfer = []) API

Potential relevant: Elsewhere in the JavaScript ecosystem, Node is now exposing the structured cloning/serialization directly through their v8 built-in module, although it is still marked as "experimental".

const v8 = require('v8');
// ...
let clone = v8.deserialize(v8.serialize(original));
annevk

comment created time in 3 months

startedRustPython/RustPython

started time in 3 months

MemberEvent

issue closeddenoland/deno

Type-only imports for importing definitions from semi-trusted sources

Motivating scenario: a service may automatically generate .d.ts definitions for its API. For a cool example see this recent blog post about automatically generating TypeScript definitions for Rust Serde types. I am working on something similar for an internal project at work that generates .d.ts definitions for our RPC interfaces. Our users need to manually copy these .d.ts files into their projects, and make sure they stay in sync.

If the service exposes these .d.ts files alongside their API, such as https://example.com/api/types.d.ts, Deno lets us handle this in a more elegant way than other tools: we can import the types directly from the API server, right next to the code that makes requests to that API server. This seems like a very attractive pattern for safe API use.

import {Post} from 'https://example.com/api/types.d.ts';

async function main() {
  const response = await fetch('https://example.com/api/posts/0');
  const post = await request.response() as Post;
  console.log(post.body);
}

However, this has the consequence that I'm importing and potentially evaluating code from every API that I depend on. For my internal use case, this is fine, but if I were integrating with several public APIs I would have some reservations. I can leave Deno's sandboxing enabled in some cases, but not all.

What I would like is the ability to indicate that these imports are intended to import types only, and throw an error if they would have any other effect. TypeScript automatically elides (removes) imports that are only used for types, so this wouldn't effect the behaviour of any allowed code, it would just disallow certain certain code.


I don't have a specific idea of what this should look like: perhaps it could automatically be applied for imports that end in .d.ts, or could be indicated with a URL pseudo-scheme, like types:https://example.com/api/types.d.ts. But it's a compelling pattern, and I'd like to be able to use it safely from Deno.

closed time in 3 months

jeremyBanks

issue commentdenoland/deno

Type-only imports for importing definitions from semi-trusted sources

Thank you for the detailed explanation! My mental model of how Deno works what not complete.

I also didn't realize that the TypeScript compiler itself throws an error (statements "not allowed in ambient contexts") if there are non-type declarations in a .d.ts file.

It looks like I have nothing to worry about. 🙂

jeremyBanks

comment created time in 3 months

issue openeddenoland/deno

Type-only imports for importing definitions from semi-trusted sources

Motivating scenario: a service may automatically generate .d.ts definitions for its API. For a cool example see this recent blog post about automatically generating TypeScript definitions for Rust Serde types. I am working on something similar for an internal project at work that generates .d.ts definitions for our RPC interfaces. Our users need to manually copy these .d.ts files into their projects, and make sure they stay in sync.

If the service exposes these .d.ts files alongside their API, such as https://example.com/api/types.d.ts, Deno lets us handle this in a more elegant way than other tools: we can import the types directly from the API server, right next to the code that makes requests to that API server. This seems like a very attractive pattern for safe API use.

import {Post} from 'https://example.com/api/types.d.ts';

async function main() {
  const response = await fetch('https://example.com/api/posts/0');
  const post = await request.response() as Post;
  console.log(post.body);
}

However, this has the consequence that I'm importing and potentially evaluating code from every API that I depend on. For my internal use case, this is fine, but if I were integrating with several public APIs I would have some reservations. I can leave Deno's sandboxing enabled in some cases, but not all.

What I would like is the ability to indicate that these imports are intended to import types only, and throw an error if they would have any other effect. TypeScript automatically elides (removes) imports that are only used for types, so this wouldn't affect the behaviour of any allowed code, it would just disallow certain certain code.


I don't have a specific idea of what this should look like: perhaps it could automatically be applied for imports that end in .d.ts, or could be indicated with a URL pseudo-scheme, like types:https://example.com/api/types.d.ts. But it's a compelling pattern, and I'd like to be able to use it safely from Deno.

created time in 3 months

more