« first day (4932 days earlier)      last day (13 days later) » 

7:33 AM
@Aran-Fey Hm, technically it does violate the specification indeed: "Final names cannot be reassigned in any scope." So the first assignment should be safe, even if it happens after the annotation.
FWIW, mypy also doesn't like it but directly complains that the value is unassigned: error: Final name must be initialized with a value [misc] and error: Cannot assign to final name "host" [misc]
 
8:06 AM
@matszwecja Using mypy it will also report that 2: error: Final name must be initialized with a value [misc]
Moreover, the documentation states that "Final names cannot be reassigned in any scope"
derp, I was scrolled up a bit
 
 
2 hours later…
9:47 AM
@MisterMiyagi the thing is it does work for a single assignment (host = "localhost") but with unpacking assignment its always considered as reassignment even if it's first time you are assigning something to that name.
 
I feel your pain. Just realised PyRight happily ignores attributes annotated literally as type.
from typing import Protocol

class Foo(Protocol):
    bar: type

def lol(foo: Foo) -> type:
    return foo.bar  # "Type of "bar" is unknown"
 
Wow, wonder how the heck that happens
 
This "unknown" stuff is super annoying.
Type "(a: Unknown, b: Unknown, *others: Unknown) -> float" cannot be assigned to type "(*args: Any, **kwargs: Any) -> float"
partially typed code is hell. :/
 
pyright really likes its Unknowns lately. Sometimes it just adds a | Unknown to a type for no apparent reason
 
 
3 hours later…
12:42 PM
@Aran-Fey congrats on your new project (rio) looks good :)
@Peilonrayz never knew that. Weird given that's the one tag that would be fine if it was on all questions, since most people just make implementation from scratch for various reasons.
@roganjosh I always made my own counter implementation before knowing about Counter but I never thought it was anything special :o
 
@NordineLotfi Thanks. It's kind of a mess still, but we're getting there...
 
 
2 hours later…
3:08 PM
@NordineLotfi Yeah the problem is well known with meta tags, and is why most sites burnated all meta tags. On CR beginner and performance are the common meta tags. [performance] is a bit of a joke at times...
 
@Aran-Fey good luck, I'm sure it will be fine
@Peilonrayz Yeah, I noticed the same with that tag on SO. Although I also did see some good stuff there because of that tag (lot of interesting low level explanation thanks to that tag)
 
 
2 hours later…
5:03 PM
@NordineLotfi I was intending to suggest that it was complicated, merely that the "closest to the metal" (really stretching the definition here) you can get in Python actually seems to do more weird stuff than the Counter method that's bundled into the standard library. That is; a newbie would probably learn more using the idiomatic Counter method than "this one weird trick" to make a dictionary into a counter.
Then again, a counter in rust would be implemented in a similar fashion to the python dictionary approach, so maybe it's more-broadly applicable understanding for programming in general
And then then again, I guess you could implement your own class and try build up a dictionary class from scratch, implementing your own hashing. That would be interesting...
 
 
2 hours later…
6:58 PM
@roganjosh I'm not really sold on your argument. Counter isn't really idiomatic in a lot of places and can't be used for a groupby -- groupby.setdefault(item.key, []).append(item). Personally I've found knowing you can swap a dict for a list when interacting with naturals of a limited size to be more eye opening and helpful than Counter.
 
 
1 hour later…
8:08 PM
Vscode's intellisense lists all kinds of internal stuff as members of my module, and I don't know how to stop that. I tried del-ing everything, and I've tried adding an __all__ to my __init__.py, but neither had an effect. I think writing a stub file would solve it, but that would be a lot of boilerplate. Is there any other solution?
On 2nd thought, a stub file would probably have the exact same problem
Unless I re-write all my classes and functions and stuff them all in the same file, I guess
 
8:43 PM
I'm only aware of python.analysis.addImport.heuristics. The setting was somewhat divisive... I'm not sure what you want exists.
Not listening to __all__ seems a little odd tho.
 
8:54 PM
Having a hard time finding out what python.analysis.addImport.heuristics does, but it seems to be about auto-adding missing imports?
 
IIRC it uses heuristics to determine import order and limited the amount of imports you see... or I enabled the wrong setting the other day.
 

« first day (4932 days earlier)      last day (13 days later) »