Skip to content
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

fix: closes #11343's [attr-defined] type errors #11345

Commits on Aug 23, 2023

  1. fix: closes pytest-dev#11343's [attr-defined] type errors

    On Windows 10.0.19045, the mypy hook is failing on pre-commit because of two [attr-defined] errors, which prevents me from staging stages. The problem was first reported in pytest-dev#11343. This PR solves the problem by adding `type ignore` comments to the erroring lines:
    
    ```
    src\_pytest\compat.py:324: error: Module has no attribute "getuid"; maybe "getpid" or "getppid"?  [attr-defined]
    testing\test_parseopt.py:294: error: Module has no attribute "getencoding"  [attr-defined]
    ```
    WarrenTheRabbit committed Aug 23, 2023
    Configuration menu
    Copy the full SHA
    2a91c63 View commit details
    Browse the repository at this point in the history

Commits on Aug 24, 2023

  1. Configuration menu
    Copy the full SHA
    7600243 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    15ebcf5 View commit details
    Browse the repository at this point in the history

Commits on Aug 25, 2023

  1. Configuration menu
    Copy the full SHA
    fe67feb View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2d5bfa8 View commit details
    Browse the repository at this point in the history

Commits on Aug 26, 2023

  1. refactor: self-document error flag with a constant

    The previous implementation required the caller
    to have knowledge of its platform's `getuid` error
    code. Although this had the benefit of replacing a
    hard-coded error value with a descriptive variable,
    the attempt at future proofing `get_user_id` was
    flagged as a poor design decision by Nicoddemus:
    to future proof the function, `get_user_id` should
    determine the error flag internally.
    
    However, future-proofing was not the reason
    the issue was opened. The issue was opened to
    resolve an `[attr-defined]` error on Windows
    platforms caused by *mypy*'s handling of
    code reachability through platform checks.
    
    Over the course of the open issue, additional housekeeping
    tasks were also undertaken:
    - adding a comment that links to an explanation of
    *mypy*'s platform and version checking requirements
    - adding a variable name and comment to clarify
    the reason for the conditional return `return uid if uid . . .`
    WarrenTheRabbit committed Aug 26, 2023
    Configuration menu
    Copy the full SHA
    f9aa628 View commit details
    Browse the repository at this point in the history

Commits on Aug 27, 2023

  1. doc: improve explanation of return values

    It is misleading to say that None is returned because
    the uid is unreliable. That implies that a uid of uknown
    integrity was retrieved. More accurately, and across all
    platforms, None indicates that no such id was determined.
    WarrenTheRabbit committed Aug 27, 2023
    Configuration menu
    Copy the full SHA
    af4ebeb View commit details
    Browse the repository at this point in the history
  2. refactor: change name of self-documenting constant

    The previous constant name implied that a user id was returned
     and that it cannot be relied upon. That is not the case. -1 is an
     error flag and the constant should identify it as such.
    WarrenTheRabbit committed Aug 27, 2023
    Configuration menu
    Copy the full SHA
    60f6566 View commit details
    Browse the repository at this point in the history
  3. doc: remove unwanted implication

    Returning None does not mean that all future calls to the underlying
    platform will result in a return value of None. It is a certainty for win32
    and Emscripten platforms but only a possibility for other platforms.
    The documentation should only state that the *current* call to the
    underlying platform was unsuccessful.
    WarrenTheRabbit committed Aug 27, 2023
    Configuration menu
    Copy the full SHA
    c7b602c View commit details
    Browse the repository at this point in the history