« first day (4376 days earlier)      last day (797 days later) » 

00:46
@roganjosh They do, but when you make them nested blueprints where it's a child of a parent the static web path will become /grandparent/parent/child/static for example. However the child static folder may be in the folder app/blueprints/grandparent/blueprints/parent/blueprints/child/static
Flask clearly knows that path as it has to map the web path to the filesystem path to serve the files. I'm trying to find out how to get that filesystem path, opposed to doing some hacky string splitting and building.
 
7 hours later…
07:17
@crypticツ This is news to me. I know that you can have separate templates for blueprints but not static. I can only think that url_for might be used to join the path up to the entry point of your app, but I have no idea how flask resolves this for you sorry
I guess it will exist in werkzeug somewhere
07:36
@NordineLotfi I'm looking at this again this morning and I don't follow what changed for this. The fact that they passed a server here shouldn't make any difference. In my case, I do pass a server but I also register a path as a shim
Because the server now ignores the base path (I'm gonna stomp this with a PR at some point, I'm sure. It's dumb), I've used:
server = flask.Flask(__name__)
@server.route('/', methods=['GET'])
def homepage():
    paths = [f"{page['name']} - {page['path']} - {page['relative_path']}" for page in page_registry.values()]

    return render_template_string(f"""
    <a href="https://testing-abcd.peak.ai/api/route/app_direct/default/home">Click Me</a>
    {paths}
    """)
I've made that button so I can at least tell that I am definitely landing on the base path page. If I can get the link working, I'll upgrade it to a straight redirect and nobody need know the abomination going on behind the scenes to make things work
 
7 hours later…
14:46
apparently a typo, also just totally incoherent stackoverflow.com/questions/74005640
15:07
I'm glad the newer members got to have their field day with that one
16:05
If you have a function like download_file_from_http_api(url) that should return contents of a remote file in a streaming manner and also somehow let the caller know the size of the file (based the content-length header; say, to let the caller display a progress bar), what return value makes the most sense? I could think of a file-like object with the content_length attribute, a chunk iterator with the content_length attribute, and a tuple of (chunk_iterator, content_length)
Another option is to use a handy function get_file_size_from_http_api(url) and call it before download_file_from_http_api(url) (which would then need to return just the file-like object/iterator), but this seems wasteful
I'd probably go for a file-like object with a size attribute
Hello, i am trying to make some images (print screens) using Windows pickpick app.
The problem is that in the pyqt5 window i want to capture i have some widgets such as QSliders and with those widgets the auto scroll of pick pick stop at this widgets.

How can i run event.ignore of QSliders,... so to stop the mouseWheelEvent ?
@vaultah I should have some code lying around that can turn an iterator or a callable into a file-like object. Let me know if you need it
16:23
Nah, thanks :) I think I've done something similar in the past
Thanks for the suggestion, I'll probably use a file-like object. download_file_from_http_api(url) will likely have to return something like AsyncFileStream or SyncFileStream depending on its type (i.e., async or plain)
 
2 hours later…
18:05
Speaking of, I have a design question. If you want to turn an iterator into a file object, you need to know whether it yields strings or bytes. I've solved this by taking str/bytes as input in the constructor (like Iterable2File(['line 1'], str)), but the problem with this is that it's impossible to write a correct type annotation for it. Should I take strings as input instead?
I annotated it as Literal[str, bytes], but apparently type checkers aren't very happy about that ¯\_(ツ)_/¯
18:22
@roganjosh I'm really tempted to try to figure out which version is causing the problem and why. Can you tell me the exact version for shinyproxy and dash? (unless either of them are forked/custom version?)
if not, I guess I could just make a test case and try it on every version, but that may take some time for shinyproxy (since it needs a docker image? although I saw somewhere that it could be set up without one on linux)
19:18
@Aran-Fey This should be doable with a TypeVar.
T = TypeVar("T", str, bytes)

class Iterable2File(Generic[T]):
    def __init__(self, iterable: Iterable[T], t: Type[T]):
        ...
I think a TypeVar would also allow subclasses of str/bytes, no?
Let me check
Hm, looks that way. :/
The type checker will constrain T it to the given type but still accept subtypes as t.
Honestly though, not a big deal. What I should be more concerned with is how useful it is, particularly when you're instantiating the class and looking at your IDE suggestions. Which is... reasonable, I guess?
(iterable: Iterable[T@Iterable2File], t: Type[T@Iterable2File])
Now that I think about it, that's actually the most correct solution. I didn't bother making iterable generic, but I should've
Hmm, on 3rd thought, the correct annotation would actually be Callable[[], T]
Or not, because I need it to return a 0-length T
Typing is truly a science
20:13
It's annoying how you constantly run into road blocks because you're trying to write an annotation for something that's not considered a "type". You need a function that returns a 0-length iterable? Too bad, Callable[[], Iterable] is the best you can do, because the length of the iterable isn't related to its type. But apparently Literal is a type.
Oct 25, 2019 at 17:16, by Aran-Fey
static typing is just half-assed contract programming
Just give us contracts already
20:29
but... contracts are just half-assed tests...
>But apparently Literal is a type.
because detecting a Literal isn't a special case of the halting problem, it's much easier static analysis than that
Nah, contracts would be public information. Your IDE could tell you that you're passing invalid arguments to a function. Tests don't enable your IDE to do that. You don't even ship tests
@KarlKnechtel Still, it proves that typing was never the goal. The goal was always to establish a contract between the caller and the callee

« first day (4376 days earlier)      last day (797 days later) »