Comments (4)
Yep, I'm happy with that! (Well, in as much as I'm happy with the type checkers...)
The only part of this, on review, that I might keep an eye on is "how should we support that fancy recursive JSON type"? It's clearly a subtype of Mapping[str, Any]
and it feels like it should work. But I don't need that but at all for my work -- it just felt more correct academically.
from referencing.
Thanks for the detailed issue, which I haven't read through fully yet :D -- but because it seems like it may at least be slightly related, I also can't figure out why newer versions of pyright seem to have issues with type invariance either! I have it pinned to 1.1.307
here in the repo's noxfile which is the newest working version. Newer versions complain about things which make no sense to me, though I've only spent a few minutes trying to poke at them.
I'll have a closer look at the rest of what you shared after the weekend, thanks for writing it up.
from referencing.
So -- I think given that the mypy part of this is partly or in whole a "known issue" with mypy -- namely python/mypy#5406 -- and given the last comment about indeed using the public objects for pyright -- I'm going to close this perhaps.
Obviously speak up if you disagree, or if you have concrete suggestions for what to tweak, as should anyone else running into trouble here.
But yeah on the mypy side specifically I'm not sure if there's anything to do until things are fixed upstream.
from referencing.
(Will probably repeatedly respond to this in piecemeal as I flip back and forth between looking at it and some other things) --
mypy doesn't understand that retrieve is an attrs-provided field:
I remember fighting with this a bit -- I think mypy doesn't understand dataclass_transform
yet or something, specifically it doesn't understand attrs
' alias
argument -- and vice versa, pyright is slightly dumb and doesn't understand that the alias argument isn't needed at all when all it's doing is automatic renaming of private attributes, so you have to write alias
even when it's not needed.
More type checker time wasting, grumble grumble.
I'm probably going to be importing Schema on the assumption that it's safe to rely on that name and using it to ensure that my annotations always match referencing
referencing.jsonschema.Schema
is definitely public -- lemme know if there's some other convention in the typing community to make that even more obvious. For that matter, so is referencing.jsonschema.SchemaRegistry
which I figured would be even more common to use, it's just Registry[Schema]
specializing the generic to something JSON Schema specific (as opposed to future support for OpenAPI or something).
from referencing.
Related Issues (20)
- Jsonschema validation 4 to 5 times slower when upgrading to referencing 0.31.0 HOT 2
- documentation uses `url` module which is no longer maintained HOT 2
- Type check errors HOT 2
- Check all $refs are resolvable HOT 6
- Resolving a `$ref` to a nested definition can fail to catch that a (bad) subschema is neither bool nor object, resulting in an `AttributeError` HOT 4
- Question regarding usage of generics HOT 5
- Are relative JSON pointers supported? HOT 2
- Invalid `type: ignore` style when checking with mypy HOT 3
- Add support for `definitions` to newer JSON Schema drafts
- TypeError: field() got an unexpected keyword argument 'alias' HOT 7
- Import fails on typing.py: AttributeError: type object 'Mapping' has no attribute '__class_getitem__' HOT 4
- sdist is missing suite HOT 1
- Consider providing `retrieve` functions with an enclosing specification
- Consider adding `referencing.jsonschema.SchemaValidatingRegistry` HOT 5
- Relative file path references not supported? HOT 3
- FYI: Small breaking changes are coming to some (non-schema author related) APIs
- Relative URL paths as $refs HOT 5
- Moving from `RefResolver` to the referencing library HOT 3
- Potential issue with attrs==22.1.0 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from referencing.