Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

ProbstDJakob
Copy link
Contributor

@ProbstDJakob ProbstDJakob commented Jan 24, 2021

Important: this PR only exists to split up the PR #208

  • add python 3.6+ type hints
  • replace applying defaults dict in LDAPSettings with actual variables, allowing type hints, checking if variable exists (e.g. IDE), and preventing supplied defaults dict (LDAPSettings.init) to inject undesired variables
  • add AbstractLDAPSearch as abstract base class
  • fix (by removing) result of search_s not being checked if None in LDAPSearch.execute
  • add conversion to string in AbstractLDAPSearch._escape_filterargs
  • rename AbstractLDAPSearch._begin(...) to AbstractLDAPSearch._search(...) and AbstractLDAPSearch._results(...) to AbstractLDAPSearch._result(...)
  • add AbstractLDAPSearch._abandon(...)
  • LDAPSearch._search(...) saves the msgid inside the object instead of returning it
  • make LDAPGroupType abstract
  • MemberDNGroupType.is_member(...) now returns bool instead of Union[bool, int]
  • remove kwargs from LDAPGroupQuery.init
  • update test mocks corresponding to the AbstractLDAPSearch changes

@ProbstDJakob ProbstDJakob changed the title chore(python): add type hints and minor changes [DO NOT REVIEW] chore(python): add type hints and minor changes Jan 24, 2021
Copy link
Member

@francoisfreitag francoisfreitag left a comment

Choose a reason for hiding this comment

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

Could you rebase on the latest master and configure a mypy tox build to validate the type annotations? Just running mypy locally shows 59 errors.

@ProbstDJakob ProbstDJakob force-pushed the type_hinting branch 4 times, most recently from 0565a58 to 6306036 Compare January 27, 2021 02:35
@ProbstDJakob
Copy link
Contributor Author

Could you rebase on the latest master and configure a mypy tox build to validate the type annotations? Just running mypy locally shows 59 errors.

I rebased the onto master and configured mypy and fixed the issues. This has been done in a later commit of #208, but already included ldap3, thus it has not been included in this PR at first.

@francoisfreitag francoisfreitag changed the title [DO NOT REVIEW] chore(python): add type hints and minor changes chore(python): add type hints and minor changes Jan 27, 2021
Copy link
Member

@francoisfreitag francoisfreitag left a comment

Choose a reason for hiding this comment

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

Can you please split the PR further, so that this PR is only focused on adding type hints. There are good changes in the suggested “minor changes”, but they should be proposed separately. The history (and reviews) are much easier to follow when changes are small, accompanied by a rationale explaining why the changes bring an improvement. It also facilitates bisecting later issues.

@ProbstDJakob ProbstDJakob force-pushed the type_hinting branch 2 times, most recently from 96c72b5 to 2936d9f Compare February 4, 2021 00:12
@ProbstDJakob
Copy link
Contributor Author

I've created a new PR (#231) to spilt this PR further up. This PR still contains some minor changes (AbstractLDAPSearch and LDAPSettings) in order to achive "good" type hints.

- add python 3.6+ type hints
- replace applying defaults dict in LDAPSettings with actual variables, allowing type hints, checking if variable exists (e.g. IDE), and preventing supplied defaults dict (LDAPSettings.__init__) to inject undesired variables
- add AbstractLDAPSearch as abstract base class
- fix (by removing) result of search_s not being checked if None in LDAPSearch.execute
- add conversion to string in AbstractLDAPSearch._escape_filterargs
- rename AbstractLDAPSearch._begin(...) to AbstractLDAPSearch._search(...) and AbstractLDAPSearch._results(...) to AbstractLDAPSearch._result(...)
- add AbstractLDAPSearch._abandon(...)
- LDAPSearch._search(...) saves the msgid inside the object instead of returning it
- make LDAPGroupType abstract
- MemberDNGroupType.is_member(...) now returns bool instead of Union[bool, int]
- remove kwargs from LDAPGroupQuery.__init__
- update test mocks corresponding to the AbstractLDAPSearch changes
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.

2 participants