Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add type assertion to the cache lookup #123

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

Merged
merged 1 commit into from
Aug 15, 2022

Conversation

masklinn
Copy link
Contributor

Currently if an incorrect type is passed in, it'll raise an error that's anything but clear, either failing in the cache lookup or in the regex application.

Instead, make the error clear by checking upfront.

Closes #122

@masklinn masklinn force-pushed the cache-type-assertion branch 2 times, most recently from 6f95648 to 1866aa2 Compare August 15, 2022 19:16
Currently if an incorrect type is passed in, it'll raise an error
that's anything but clear, either failing in the cache lookup or in
the regex application.

Instead, make the error clear by checking upfront.

Closes ua-parser#122
@masklinn masklinn force-pushed the cache-type-assertion branch from 1866aa2 to d0ca1df Compare August 15, 2022 19:20
@masklinn masklinn merged commit 05e0e41 into ua-parser:master Aug 15, 2022
@masklinn masklinn deleted the cache-type-assertion branch August 15, 2022 19:25
masklinn added a commit to masklinn/uap-python that referenced this pull request Aug 20, 2022
- removed version bound from `setup_requires`, allows building from
  source when only PyYaml 6.0 is available (and downloading 5.4 is
  not), ua-parser#121, ua-parser#125
- added type assertion to parser lookup, to make the error clearer on
  type error, ua-parser#122, ua-parser#123
- fixed `setup.py build_regexes` and `setup.py build` for non-in-place
  builds, ua-parser#127
@masklinn masklinn mentioned this pull request Aug 20, 2022
masklinn added a commit that referenced this pull request Aug 20, 2022
- removed version bound from `setup_requires`, allows building from
  source when only PyYaml 6.0 is available (and downloading 5.4 is
  not), #121, #125
- added type assertion to parser lookup, to make the error clearer on
  type error, #122, #123
- fixed `setup.py build_regexes` and `setup.py build` for non-in-place
  builds, #127

def _lookup(ua, args):
if not isinstance(ua, _UA_TYPES):
raise TypeError("Expected user agent to be a string, got %r" % ua)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't that be type(ua) at the end?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't really matter, this prints the value which I assumed would be more relevant / understandable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cache exception
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.