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

PDM update unconstrained not showing all outdated packages #1356

Open
1 task done
lyz-code opened this issue Sep 2, 2022 · 1 comment
Open
1 task done

PDM update unconstrained not showing all outdated packages #1356

lyz-code opened this issue Sep 2, 2022 · 1 comment
Labels
🐛 bug Something isn't working

Comments

@lyz-code
Copy link
Contributor

lyz-code commented Sep 2, 2022

  • I have searched the issue tracker and believe that this is not a duplicate.

Make sure you run commands with -v flag before pasting the output.
When running pdm update --unconstrained --dry-run as suggested here to detect outdated packages, some outdated packages are not showing up. Maybe the root cause is the same as with this other issue.

Steps to reproduce

  • Install a combination of packages where one of them is outdated pdm add flakeheaven 'flake8>=3.9.2', this installs flakeheaven 0.11.0 when the latest is 3.0.0, and flake8 4.0.1 when the latest is 5.0.3.
  • Run pdm update --dry-run --unconstrained

Actual behavior

No package is shown to be outdated

Expected behavior

flakeheaven and flake8 are listed between the packages to update

Environment Information

# Paste the output of `pdm info && pdm info --env` below:
# Paste the output of `pdm info && pdm info --env` below:
PDM version:
  2.1.3
Python Interpreter:
  /tmp/tmp.ANJTs8czk0/env/bin/python (3.9)
Project Root:
  /tmp/tmp.ANJTs8czk0
Project Packages:
  None
{
  "implementation_name": "cpython",
  "implementation_version": "3.9.10",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "4.19.0-5-amd64",
  "platform_system": "Linux",
  "platform_version": "#1 SMP Debian 4.19.37-5+deb10u1 (2019-07-19)",
  "python_full_version": "3.9.10",
  "platform_python_implementation": "CPython",
  "python_version": "3.9",
  "sys_platform": "linux"
}
@lyz-code lyz-code added the 🐛 bug Something isn't working label Sep 2, 2022
@lyz-code
Copy link
Contributor Author

lyz-code commented Sep 2, 2022

I think I understand what it's happening, the command is trying to check the group of packages that would be installed if there were no constrains specified by the user, but downstream dependencies are respected, therefore if they are preventing flake8 from reaching 5.0.3 it will never show up.

Maybe the need of an outdated is back again. The information looks to be there, at least when you do pdm show flake8.

lyz-code added a commit to lyz-code/blue-book that referenced this issue Sep 4, 2022
[Abstract syntax trees](https://en.wikipedia.org/wiki/Abstract_syntax_tree)
(AST) is a tree representation of the abstract syntactic structure of text
(often source code) written in a formal language. Each node of the tree denotes
a construct occurring in the text.

The syntax is "abstract" in the sense that it does not represent every detail
appearing in the real syntax, but rather just the structural or content-related
details. For instance, grouping parentheses are implicit in the tree structure,
so these do not have to be represented as separate nodes. Likewise, a syntactic
construct like an if-condition-then statement may be denoted by means of
a single node with three branches.

This distinguishes abstract syntax trees from concrete syntax trees,
traditionally designated parse trees. Parse trees are typically built by
a parser during the source code translation and compiling process. Once built,
additional information is added to the AST by means of subsequent processing,
e.g., contextual analysis.

Abstract syntax trees are also used in program analysis and program transformation systems.

[`pyparsing`](https://github.com/pyparsing/pyparsing/) looks to be a good candidate to [construct an AST](https://stackoverflow.com/questions/1721553/how-to-construct-an-abstract-syntax-tree)

feat(python_snippets#Fix R1728: Consider using a generator): Fix R1728: Consider using a generator

Removing `[]` inside calls that can use containers or generators should be
considered for performance reasons since a generator will have an upfront cost
to pay. The performance will be better if you are working with long lists or
sets.

Problematic code:

```python
list([0 for y in list(range(10))])  # [consider-using-generator]
tuple([0 for y in list(range(10))])  # [consider-using-generator]
sum([y**2 for y in list(range(10))])  # [consider-using-generator]
max([y**2 for y in list(range(10))])  # [consider-using-generator]
min([y**2 for y in list(range(10))])  # [consider-using-generator]
```

Correct code:

```python
list(0 for y in list(range(10)))
tuple(0 for y in list(range(10)))
sum(y**2 for y in list(range(10)))
max(y**2 for y in list(range(10)))
min(y**2 for y in list(range(10)))
```

feat(python_snippets#Fix W1510: Using subprocess.run without explicitly set check is not recommended): Fix W1510: Using subprocess.run without explicitly set check is not recommended

The `run` call in the example will succeed whether the command is successful or
not. This is a problem because we silently ignore errors.

```python
import subprocess
def example():
    proc = subprocess.run("ls")
    return proc.stdout
```

When we pass `check=True`, the behavior changes towards raising an exception
when the return code of the command is non-zero.

feat(python_snippets#Convert bytes to string): Convert bytes to string

```python
byte_var.decode('utf-8')
```

feat(python_snippets#Use pipes with subprocess): Use pipes with subprocess

To use pipes with subprocess you need to use the flag `check=True` which is [a
bad idea](https://github.com/duo-labs/dlint/blob/master/docs/linters/DUO116.md).
Instead you should use two processes and link them together in python:

```python
ps = subprocess.Popen(('ps', '-A'), stdout=subprocess.PIPE)
+output = subprocess.check_output(('grep', 'process_name'), stdin=ps.stdout)
ps.wait()
```

feat(python_snippets#Pass input to the stdin of a subprocess): Pass input to the stdin of a subprocess

```python
import subprocess
p = subprocess.run(['myapp'], input='data_to_write', text=True)
```

feat(python_snippets#Copy and paste from clipboard): Copy and paste from clipboard

You can use [many libraries](https://www.delftstack.com/howto/python/python-copy-to-clipboard/) to
do it, but if you don't want to add any other dependencies you can use
`subprocess run`.

To copy from the `selection` clipboard, assuming you've got `xclip` installed,
you could do:

```python
subprocess.run(
    ['xclip', '-selection', 'clipboard', '-i'],
    input='text to be copied',
    text=True,
    check=True,
)
```

To paste it:

```python
subprocess.check_output(
    ['xclip', '-o', '-selection', 'clipboard']
).decode('utf-8')
```

Good luck testing that in the CI xD

feat(cooking_software): Finish the state of the art analysis

Review Cooklang, KookBook, RecipeSage, Mealie and Chowdown

feat(pdm#Supporting pre-releases): Supporting pre-releases

To help package maintainers, you can allow pre-releases to be validate
candidates, that way you'll get the issues sooner. It will mean more time to
maintain the broken CIs if you update your packages daily (as you should!), but
it's the least you can do to help your downstream library maintainers

By default, `pdm`'s dependency resolver will ignore prereleases unless there are
no stable versions for the given version range of a dependency. This behavior
can be changed by setting allow_prereleases to true in `[tool.pdm]` table:

```toml
[tool.pdm]
allow_prereleases = true
```

feat(pdm#Solve circular dependencies): Solve circular dependencies

Sometimes `pdm` is not able to [locate the best package combination](pdm-project/pdm#1354), or it does too
many loops, so to help it you can update your version constrains so that it has
the minimum number of candidates.

To solve circular dependencies we first need to locate what are the conflicting
packages, [`pdm` doesn't make it easy to detect them](pdm-project/pdm#1354). Locate all the outdated
packages by doing `pdm show` on each package until [this issue is solved](pdm-project/pdm#1356) and run `pdm update {package} --unconstrained` for each of them. If you're already on the latest
version, update your `pyproject.toml` to match the latest state.

Once you have everything to the latest compatible version, you can try to
upgrade the rest of the packages one by one to the latest with
`--unconstrained`.

In the process of doing these steps you'll see some conflicts in the
dependencies that can be manually solved by preventing those versions to be
installed or maybe changing the `python-requires`.

feat(use_warnings#Use environmental variables): Use environmental variables to evolve your packages

A cleaner way to handle the package evolve is with environmental variables, that way you don't
need to change the signature of the function twice. I've learned this from
[boto](boto/botocore#2705) where they informed their
users this way:

* If you wish to test the new feature we have created a new environment variable
    `BOTO_DISABLE_COMMONNAME`. Setting this to `true` will suppress the warning and
    use the new functionality.
* If you are concerned about this change causing disruptions, you can pin your
    version of `botocore` to `<1.28.0` until you are ready to migrate.
* If you are only concerned about silencing the warning in your logs, use
    `warnings.filterwarnings` when instantiating a new service client.

    ```python
    import warnings
    warnings.filterwarnings('ignore', category=FutureWarning, module='botocore.client')
    ```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant