-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactoring and Typing #261
Conversation
141f3fa
to
cc0a4ff
Compare
Hi @betaboon, you decided to move a lot of code to dedicated modules. While I understand the reasons behind, and I see it as valuable, I would keep it as a complete different task. The way it is now complicates understanding what's changing because of type hints and what is just code that got moved to a different file. |
@mindflayer I'm trying to keep those steps in individual commits so they are easier to follow. i hope looking at changes commit-by-commit makes more sense. do you have any suggestions how to approach this differently? |
For a PR that is meant to introduce type hints is probably too much. I'd keep them as two completely separated tasks, and avoid breaking interfaces (names, import paths, etc). |
When we have type hints in place, and we are sure that nothing broke, we can start discussing about introducing new modules (and how they should be called). |
Imagine yourself as a Mocket user, with a broken CI, trying to understand what happened, while staring at a "thousand lines changed" PR which was only supposed to add type hints (I am not saying "only" because I see it as a simple task). |
for clarity: Sorry for stomping in, I didn't mean to intrude or offend anyone. this PR wasn't really intended to get merged as a whole, but rather to play around with approaches to get this typed and show you what I'm thinking. having poked around the codebase i believe refactoring is required to get it into a state where it can be fully typed. If you're interested in my contributions to get there I'd like to send individual PRs for the steps that i have in mind. Every step must keep the tests green and the API backwards-compatible. These are the steps i have in mind:
I'd be quite interested to hear what you're thinking. Thanks for your patience and understanding PS: i just reset this branch to only contain 1. and 2. and moved my other wip-stuff into a separate branch. |
Quality Gate passedIssues Measures |
No offence taken, and let me add you are the first contributor that is not just interested - which is still legit and welcome - in having something fixed or added. No problems with 1/2/3, it just makes sense. Point 6: yes please! :) Being wanting to make it better for ages. Point 7: let's keep the main class as it is and implement mixins instead. Not sure, but maybe that's exactly what you had in mind. Point 8: I see it more as something better solved by creating interfaces than a problem solved by standard sub-classing. What do you think? |
I am more than happy to see this happening, if my previous answer what not clear enough. And thank you, btw. :) |
i agree. keeping the old names alive, until they can get explicitly deprecated.
I'm actually thinking about so basically
Yeah i'm thinking off i think for responses it would actually be better to do |
I don't think there is a specific need for having a |
i agree that there is not specific need, but tbh the i'd prefer having that cleanly split, so that you can actually know what is part of which api. |
Mocket is basically mocking all the entrypoints available to create a |
i'm just trying to introduce the state-object, but i have a feeling i need to do otherwise I keep struggling with cyclical imports |
@mindflayer what do you think about the 2 commits in this PR? should i move them into a separate/new PR, to keep this pr open for discussion? |
the commits addressing 1 and 2 (convert imports to absolute and remove the compat-type) are in this branch: the commits addressing 4 (split the commits addressing 3 (introduce a state-object) are on this branch: |
I've just merged those two. |
ok. I'll create the next PR then :) |
Now that I spent more time looking into it, I don't particularly like this |
the as the state is set during import-time, this leads to cyclic-imports between eg moving this out into a class and the instatiating the state once, helps getting rid of the cyclic-imports. |
@mindflayer It's quite hard to get this backwards compatible. how set are you on keeping that part backwards compatible? |
This would mean that every test suite relying on recorded sessions would break (producing new records). What are your struggles? |
multiple aspects:
|
Why would this be a problem? It's definitely better in terms of memory management, since Mocket does not have to remember everything before dumping it on file. The other two points could be solved without impacting on backwards compatibility. This said, I was already considering refactoring that part of Mocket, I could take it. |
Also: the fact that the JSON mocks are dumped with 2 spaces shows that Mocket is agnostic to the formatting, which to me sounds like a pros. |
imho doing json-serialization and filesystem-io (twice) on every request is a bigger downside than keeping the requests in memory until it is being written.
i was just a little confused that the code is supposed do do 4-indent, but the files in the tests are 2-indent. i'll tinker around some more to find ways to keep this backwards-compatible. just thought it couldn't hurt asking your stance first :) |
No description provided.