Remove the given names from the :attr:`_engine.URL.query` dictionary, returning the new :class:`_engine.URL`. E.g.:: url = url.difference_update_query(["foo", "bar"]) Equivalent to using :meth:`_engine.URL.set` as follows:: url = url.set(
(self, names: Iterable[str])
| 533 | return self.update_query_pairs(query_parameters.items(), append=append) |
| 534 | |
| 535 | def difference_update_query(self, names: Iterable[str]) -> URL: |
| 536 | """ |
| 537 | Remove the given names from the :attr:`_engine.URL.query` dictionary, |
| 538 | returning the new :class:`_engine.URL`. |
| 539 | |
| 540 | E.g.:: |
| 541 | |
| 542 | url = url.difference_update_query(["foo", "bar"]) |
| 543 | |
| 544 | Equivalent to using :meth:`_engine.URL.set` as follows:: |
| 545 | |
| 546 | url = url.set( |
| 547 | query={ |
| 548 | key: url.query[key] |
| 549 | for key in set(url.query).difference(["foo", "bar"]) |
| 550 | } |
| 551 | ) |
| 552 | |
| 553 | .. versionadded:: 1.4 |
| 554 | |
| 555 | .. seealso:: |
| 556 | |
| 557 | :attr:`_engine.URL.query` |
| 558 | |
| 559 | :meth:`_engine.URL.update_query_dict` |
| 560 | |
| 561 | :meth:`_engine.URL.set` |
| 562 | |
| 563 | """ |
| 564 | |
| 565 | if not set(names).intersection(self.query): |
| 566 | return self |
| 567 | |
| 568 | return URL( |
| 569 | self.drivername, |
| 570 | self.username, |
| 571 | self.password, |
| 572 | self.host, |
| 573 | self.port, |
| 574 | self.database, |
| 575 | util.immutabledict( |
| 576 | { |
| 577 | key: self.query[key] |
| 578 | for key in set(self.query).difference(names) |
| 579 | } |
| 580 | ), |
| 581 | ) |
| 582 | |
| 583 | @property |
| 584 | def normalized_query(self) -> Mapping[str, Sequence[str]]: |